mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-29 17:37:55 +00:00
parallel --shebang-warp for ::: works.
This commit is contained in:
parent
45763bc601
commit
0b1896c368
17
src/parallel
17
src/parallel
|
@ -923,14 +923,27 @@ sub read_options {
|
||||||
# @ARGV without --options
|
# @ARGV without --options
|
||||||
# This must be done first as this may exec myself
|
# This must be done first as this may exec myself
|
||||||
if(defined $ARGV[0] and ($ARGV[0]=~/^--shebang / or
|
if(defined $ARGV[0] and ($ARGV[0]=~/^--shebang / or
|
||||||
|
$ARGV[0]=~/^--shebang-wrap / or
|
||||||
$ARGV[0]=~/^--hashbang /)) {
|
$ARGV[0]=~/^--hashbang /)) {
|
||||||
# Program is called from #! line in script
|
# Program is called from #! line in script
|
||||||
$ARGV[0]=~s/^--shebang *//; # remove --shebang if it is set
|
# remove --shebang-wrap if it is set
|
||||||
$ARGV[0]=~s/^--hashbang *//; # remove --hashbang if it is set
|
$::opt_shebang_wrap = ($ARGV[0]=~s/^--shebang-?wrap *//);
|
||||||
|
# remove --shebang if it is set
|
||||||
|
$::opt_shebang = ($ARGV[0]=~s/^--shebang *//);
|
||||||
|
# remove --hashbang if it is set
|
||||||
|
$::opt_shebang .= ($ARGV[0]=~s/^--hashbang *//);
|
||||||
|
if($::opt_shebang) {
|
||||||
my $argfile = shell_quote_scalar(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";
|
||||||
}
|
}
|
||||||
|
if($::opt_shebang_wrap) {
|
||||||
|
# exec myself to split $ARGV[0] into separate fields
|
||||||
|
my $parser = shell_quote_scalar(shift @ARGV);
|
||||||
|
my $scriptfile = shell_quote_scalar(shift @ARGV);
|
||||||
|
exec "$0 $parser $scriptfile ::: @ARGV";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Getopt::Long::Configure("bundling","pass_through");
|
Getopt::Long::Configure("bundling","pass_through");
|
||||||
# Check if there is a --profile to set @::opt_profile
|
# Check if there is a --profile to set @::opt_profile
|
||||||
|
|
27
testsuite/tests-to-run/parallel-local21.sh
Normal file
27
testsuite/tests-to-run/parallel-local21.sh
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "### Test basic --shebang-wrap"
|
||||||
|
cat <<EOF > /tmp/test--shebang-wrap
|
||||||
|
#!/usr/local/bin/parallel --shebang-wrap /usr/bin/perl
|
||||||
|
|
||||||
|
print "Shebang from perl with args @ARGV\n";
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 755 /tmp/test--shebang-wrap
|
||||||
|
/tmp/test--shebang-wrap arg1 arg2
|
||||||
|
echo "### Same as"
|
||||||
|
parallel /usr/bin/perl /tmp/test--shebang-wrap ::: arg1 arg2
|
||||||
|
|
||||||
|
echo "### Test --shebang-wrap with parser options"
|
||||||
|
cat <<EOF > /tmp/test--shebang-wrap
|
||||||
|
#!/usr/local/bin/parallel --shebang-wrap /usr/bin/perl -p
|
||||||
|
|
||||||
|
print "Shebang from perl with args @ARGV\n";
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 755 /tmp/test--shebang-wrap
|
||||||
|
/tmp/test--shebang-wrap <(seq 2) <(seq 11 12)
|
||||||
|
echo "### Same as"
|
||||||
|
parallel /usr/bin/perl\ -p /tmp/test--shebang-wrap ::: <(seq 2) <(seq 11 12)
|
||||||
|
|
||||||
|
|
24
testsuite/wanted-results/parallel-local21
Normal file
24
testsuite/wanted-results/parallel-local21
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
### Test basic --shebang-wrap
|
||||||
|
Shebang from perl with args arg1
|
||||||
|
Shebang from perl with args arg2
|
||||||
|
### Same as
|
||||||
|
Shebang from perl with args arg1
|
||||||
|
Shebang from perl with args arg2
|
||||||
|
### Test --shebang-wrap with parser options
|
||||||
|
Shebang from perl with args
|
||||||
|
1
|
||||||
|
Shebang from perl with args
|
||||||
|
2
|
||||||
|
Shebang from perl with args
|
||||||
|
11
|
||||||
|
Shebang from perl with args
|
||||||
|
12
|
||||||
|
### Same as
|
||||||
|
Shebang from perl with args
|
||||||
|
1
|
||||||
|
Shebang from perl with args
|
||||||
|
2
|
||||||
|
Shebang from perl with args
|
||||||
|
11
|
||||||
|
Shebang from perl with args
|
||||||
|
12
|
Loading…
Reference in a new issue