parallel: quoting of replacement string.

This commit is contained in:
Ole Tange 2014-12-26 12:02:31 +01:00
parent dd9d647e81
commit 8bcb05813b
2 changed files with 10 additions and 5 deletions

View file

@ -1481,7 +1481,7 @@ sub shell_quote {
# @shell_quoted_strings = string quoted with \ as needed by the shell
my @strings = (@_);
for my $a (@strings) {
$a =~ s/([\002-\011\013-\032\\\#\?\`\(\)\{\}\[\]\*\>\<\~\|\; \"\!\$\&\'\202-\377])/\\$1/g;
$a =~ s/([\002-\011\013-\032\\\#\?\`\(\)\{\}\[\]\^\*\>\<\~\|\; \"\!\$\&\'\202-\377])/\\$1/g;
$a =~ s/[\n]/'\n'/g; # filenames with '\n' is quoted using \'
}
return wantarray ? @strings : "@strings";
@ -7210,6 +7210,8 @@ sub replaced {
my $regexp = join('|', map { my $s = $_; $s =~ s/(\W)/\\$1/g; $s }
sort { length $b <=> length $a } keys %replace);
for(@target) {
# ::debug("replace","Replace in ",::my_dump($_));
# TODO can this be /o ?
s/($regexp)/join(" ",@{$replace{$1}})/ge;
}
}
@ -7287,8 +7289,9 @@ sub new {
# Add {} if no replacement strings in @command
($replacecount_ref, $len_ref, @command) =
replacement_counts_and_lengths(@command);
if("@command" =~ /^\S*\257</) {
# Replacement string is (part of) the command (and not just argument)
if("@command" =~ /^[^ \t\n=]*\257</) {
# Replacement string is (part of) the command (and not just
# argument or variable definition V1={})
# E.g. parallel {}, parallel my_{= s/_//=}, parallel {2}
# Do no quote (Otherwise it will fail if the input contains spaces)
$Global::noquote = 1;

View file

@ -1,11 +1,12 @@
### Test stdin goes to first command only ("-" as argument)
Academic tradition requires you to cite works you base your article on.
When using programs that use GNU Parallel to process data for publication please cite:
O. Tange (2011): GNU Parallel - The Command-Line Power Tool,
;login: The USENIX Magazine, February 2011:42-47.
This helps funding further development; and it won't cost you a cent.
Or you can get GNU Parallel without this requirement by paying 10000 EUR.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing.
To silence this citation notice run 'parallel --bibtex' once or use '--no-notice'.
@ -14,13 +15,14 @@ via first cat
cat -
via pseudotty
### Test stdin goes to first command only ("cat" as argument)
Academic tradition requires you to cite works you base your article on.
When using programs that use GNU Parallel to process data for publication please cite:
O. Tange (2011): GNU Parallel - The Command-Line Power Tool,
;login: The USENIX Magazine, February 2011:42-47.
This helps funding further development; and it won't cost you a cent.
Or you can get GNU Parallel without this requirement by paying 10000 EUR.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing.
To silence this citation notice run 'parallel --bibtex' once or use '--no-notice'.