From 358b9091f6bc15b01ed3bb57ecdd0861b1a0ef81 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sat, 28 Sep 2013 17:44:54 +0200 Subject: [PATCH] parallel: Fixed bug #40137: SHELL not bash: Warning when exporting funcs. --- src/parallel | 6 ++++++ testsuite/tests-to-run/parallel-local-ssh1.sh | 6 +++++- testsuite/wanted-results/parallel-local-ssh1 | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/parallel b/src/parallel index 3c9eccae..637af7cb 100755 --- a/src/parallel +++ b/src/parallel @@ -1093,6 +1093,12 @@ sub parse_env_var { my @qcsh = map { my $a=$_; "setenv $a " . env_quote($ENV{$a}) } @vars; my @qbash = map { my $a=$_; "export $a=" . env_quote($ENV{$a}) } @vars; my @bash_functions = grep { substr($ENV{$_},0,4) eq "() {" } @vars; + if(@bash_functions) { + # Functions are not supported for all shells + if($ENV{'SHELL'} !~ m:/(bash|rbash|zsh|rzsh|dash|ksh):) { + ::warning("Shell functions may not be supported in $ENV{'SHELL'}\n"); + } + } push @qbash, map { my $a=$_; "eval $a\"\$$a\"" } @bash_functions; # Create lines like: diff --git a/testsuite/tests-to-run/parallel-local-ssh1.sh b/testsuite/tests-to-run/parallel-local-ssh1.sh index 9b4c99fc..57d596e5 100644 --- a/testsuite/tests-to-run/parallel-local-ssh1.sh +++ b/testsuite/tests-to-run/parallel-local-ssh1.sh @@ -1,6 +1,6 @@ #!/bin/bash -cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/ | parallel -j10 -k -L1 +cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/ | stdout parallel -j10 -k -L1 echo '### Test bug #34241: --pipe should not spawn unneeded processes' seq 5 | ssh csh@lo parallel -k --block 5 --pipe -j10 cat\\\;echo Block_end @@ -9,6 +9,10 @@ echo '### --env _' echo '### --env _ with explicit mentioning of normally ignored var $DISPLAY' fUbAr="OK FUBAR" parallel -S csh@lo --env DISPLAY,_ echo '$fUbAr $DISPLAY' ::: test +echo 'bug #40137: SHELL not bash: Warning when exporting funcs' + . <(printf 'myfunc() {\necho $1\n}'); export -f myfunc; parallel --env myfunc -S lo myfunc ::: no_warning + . <(printf 'myfunc() {\necho $1\n}'); export -f myfunc; SHELL=/bin/sh parallel --env myfunc -S lo myfunc ::: warning + echo '### --filter-hosts --slf <()' parallel --nonall --filter-hosts --slf <(echo localhost) echo OK diff --git a/testsuite/wanted-results/parallel-local-ssh1 b/testsuite/wanted-results/parallel-local-ssh1 index 7f3579e0..2fa377d3 100644 --- a/testsuite/wanted-results/parallel-local-ssh1 +++ b/testsuite/wanted-results/parallel-local-ssh1 @@ -10,6 +10,10 @@ Block_end DISPLAY: Undefined variable. ### --env _ with explicit mentioning of normally ignored var $DISPLAY OK FUBAR :0.0 test +bug #40137: SHELL not bash: Warning when exporting funcs +no_warning +warning +parallel: Warning: Shell functions may not be supported in /bin/sh ### --filter-hosts --slf <() OK ### bug #40002: --files and --nonall seem not to work together: