parallel: --shebang now works even if crazy people name their executable "<> or space.

This commit is contained in:
Ole Tange 2012-06-08 23:45:06 +02:00
parent f8d0d43c7b
commit 2c29653012
2 changed files with 4 additions and 5 deletions

View file

@ -860,10 +860,9 @@ sub read_options {
# Program is called from #! line in script # Program is called from #! line in script
$ARGV[0]=~s/^--shebang *//; # remove --shebang if it is set $ARGV[0]=~s/^--shebang *//; # remove --shebang if it is set
$ARGV[0]=~s/^--hashbang *//; # remove --hashbang if it is set $ARGV[0]=~s/^--hashbang *//; # remove --hashbang if it is set
my $argfile = pop @ARGV; my $argfile = shell_quote_scalar(pop @ARGV);
# exec myself to split $ARGV[0] into separate fields # exec myself to split $ARGV[0] into separate fields
exec "$0 --skip-first-line -a $argfile @ARGV"; exec "$0 --skip-first-line -a $argfile @ARGV";
#exec "tail -n +1 $argfile | $0 @ARGV";
} }
Getopt::Long::Configure("bundling","pass_through"); Getopt::Long::Configure("bundling","pass_through");

View file

@ -21,14 +21,14 @@ chmod 755 /tmp/shebang
/tmp/shebang /tmp/shebang
echo '### Test of #! with 2 files as input (2 columns)' echo '### Test of #! with 2 files as input (2 columns)'
cat >/tmp/shebang <<EOF cat >'/tmp/she <bang>"' <<EOF
#!/usr/local/bin/parallel --shebang -rk --xapply -a /tmp/123 echo #!/usr/local/bin/parallel --shebang -rk --xapply -a /tmp/123 echo
A A
B B
C C
EOF EOF
chmod 755 /tmp/shebang chmod 755 '/tmp/she <bang>"'
seq 1 3 >/tmp/123 seq 1 3 >/tmp/123
/tmp/shebang '/tmp/she <bang>"'
echo '### bug #36595: silent loss of input with --pipe and --sshlogin' echo '### bug #36595: silent loss of input with --pipe and --sshlogin'
seq 10000 | xargs | parallel --pipe -S 10/localhost cat | wc seq 10000 | xargs | parallel --pipe -S 10/localhost cat | wc