The code for my website uses this piece of code for automatic deployment on the server (Ubuntu).
cmd = \'cd \' + checkout_dir + \' && \' +
Not pretty, but hopefully a workaround.
cmd = 'cd ' + checkout_dir + ' && ' +
'r=$(' svn_command + ' st | ' +
"awk '$2 !~ /^deploy/{print $2}' | tac) && " +
'test "$r" && ' +
svn_command + ' revert -R $r && ' +
svn_command + ' up -r ' + options.revision
I'm not convinced that the tac
is necessary or useful. I refactored the first grep
into the Awk script for efficiency and aesthetic reasons.
To solve the general "my xargs
lacks -r
" problem, the gist of the solution is to convert
stuff | xargs -r cmd
into
var=$(stuff)
test "$var" && cmd $var
The unquoted $var
will only work if it doesn't contain file names with spaces or other surprises; but then bare-bones xargs
without the GNU extensions suffers from the same problem.