From c2a2b34abf6781c44a3c368be5d87ceba1d6d5d5 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sun, 17 Jul 2011 03:03:57 +0200 Subject: [PATCH] Fixed bug #33740: If the remote computer runs CSH the remote does not set PARALLEL_* vars correctly. --- src/parallel | 6 ++++-- testsuite/tests-to-run/test15.sh | 7 +++---- testsuite/tests-to-run/test61.sh | 9 ++++++--- testsuite/tests-to-run/test63.sh | 3 ++- testsuite/wanted-results/test61 | 9 ++++++++- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/parallel b/src/parallel index f9916efc..9fcf5c16 100755 --- a/src/parallel +++ b/src/parallel @@ -2941,8 +2941,10 @@ sub sshlogin_wrap { # We need to save the exit status of the job $post = '_EXIT_status=$?; '.$post.' exit $_EXIT_status;'; } - my $parallel_env = 'PARALLEL_SEQ=$PARALLEL_SEQ\;export PARALLEL_SEQ\;'. - 'PARALLEL_PID=$PARALLEL_PID\;export PARALLEL_PID\;'; + # If the remote login shell is (t)csh then use 'setenv' + # otherwise use 'export' + my $parallel_env = + q{'eval `echo $SHELL | grep -E "/(t)?csh" > /dev/null && echo setenv PARALLEL_SEQ '$PARALLEL_SEQ'\; setenv PARALLEL_PID '$PARALLEL_PID' || echo PARALLEL_SEQ='$PARALLEL_SEQ'\;export PARALLEL_SEQ\;PARALLEL_PID='$PARALLEL_PID'\;export PARALLEL_PID` ;'}; if($::opt_workdir) { $self->{'sshlogin_wrap'} = ($pre . "$sshcmd $serverlogin $parallel_env " . ::shell_quote_scalar("cd ".$self->workdir()." && ") diff --git a/testsuite/tests-to-run/test15.sh b/testsuite/tests-to-run/test15.sh index e5b30b1d..f1b0b6d1 100755 --- a/testsuite/tests-to-run/test15.sh +++ b/testsuite/tests-to-run/test15.sh @@ -83,12 +83,11 @@ echo '### Test -x' (seq 1 10; echo 1234; seq 12 15) | stdout parallel -j1 -km -s 10 -x echo (seq 1 10; echo 1234; seq 12 15) | stdout parallel -j1 -kX -s 10 -x echo (seq 1 10; echo 1234; seq 12 15) | stdout xargs -s 10 -x echo -EOF echo '### Test -a and --arg-file: Read input from file instead of stdin' -seq 1 10 >/tmp/$$ -parallel -k -a /tmp/$$ echo -parallel -k --arg-file /tmp/$$ echo +seq 1 10 >/tmp/$$-1; parallel -k -a /tmp/$$-1 echo +seq 1 10 >/tmp/$$-2; parallel -k --arg-file /tmp/$$-2 echo +EOF #echo '### Test bugfix if no command given' #(echo echo; seq 1 5; perl -e 'print "z"x1000000'; seq 12 15) | stdout parallel -j1 -km -s 10 diff --git a/testsuite/tests-to-run/test61.sh b/testsuite/tests-to-run/test61.sh index f29e4d41..240db0b8 100644 --- a/testsuite/tests-to-run/test61.sh +++ b/testsuite/tests-to-run/test61.sh @@ -3,9 +3,12 @@ SERVER1=parallel-server3 SERVER2=parallel-server2 +cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/ | parallel -j0 -k echo '### Test --return of weirdly named file' -stdout parallel --return {} -vv -S $SERVER1 echo '>'{} ::: 'aa<${#}" b' -rm 'aa<${#}" b' +stdout parallel --return {} -vv -S $SERVER1 echo '>'{} ::: 'aa<${#}" b'; rm 'aa<${#}" b' + +echo '### Test if remote login shell is csh' +stdout parallel -vv -S csh@localhost 'echo $PARALLEL_PID $PARALLEL_SEQ {}| wc -w' ::: a b c echo '### Test {} multiple times in different commands' seq 10 | parallel -v -Xj1 echo {} \; echo {} @@ -21,4 +24,4 @@ parallel -j1 -kX echo {}-{.} ::: a ::: b parallel -j2 -kX echo {}-{.} ::: a b ::: c d parallel -j2 -kX echo {}-{.} ::: a b c ::: d e f parallel -j0 -kX echo {}-{.} ::: a b c ::: d e f - +EOF diff --git a/testsuite/tests-to-run/test63.sh b/testsuite/tests-to-run/test63.sh index 0af30b4a..86bb5f66 100644 --- a/testsuite/tests-to-run/test63.sh +++ b/testsuite/tests-to-run/test63.sh @@ -1,5 +1,6 @@ #!/bin/bash +cat <<'EOF' | parallel -j0 -k echo '### Test -q' parallel -kq perl -e '$ARGV[0]=~/^\S+\s+\S+$/ and print $ARGV[0],"\n"' ::: "a b" c "d e f" g "h i" @@ -7,4 +8,4 @@ echo '### Test -q {#}' parallel -kq echo {#} ::: a b parallel -kq echo {\#} ::: a b parallel -kq echo {\\#} ::: a b - +EOF diff --git a/testsuite/wanted-results/test61 b/testsuite/wanted-results/test61 index 966bd64e..712edeb3 100644 --- a/testsuite/wanted-results/test61 +++ b/testsuite/wanted-results/test61 @@ -1,5 +1,12 @@ ### Test --return of weirdly named file -ssh parallel-server3 PARALLEL_SEQ=$PARALLEL_SEQ\;export PARALLEL_SEQ\;PARALLEL_PID=$PARALLEL_PID\;export PARALLEL_PID\; echo\ \>aa\\\<\\\${\\\#}\\\"\\\ b;_EXIT_status=$?; rsync -rlDzR -essh parallel-server3:././aa\\\<\\\${\\\#}\\\"\\\ b ./; exit $_EXIT_status; +ssh parallel-server3 'eval `echo $SHELL | grep -E "/(t)?csh" > /dev/null && echo setenv PARALLEL_SEQ '$PARALLEL_SEQ'\; setenv PARALLEL_PID '$PARALLEL_PID' || echo PARALLEL_SEQ='$PARALLEL_SEQ'\;export PARALLEL_SEQ\;PARALLEL_PID='$PARALLEL_PID'\;export PARALLEL_PID` ;' echo\ \>aa\\\<\\\${\\\#}\\\"\\\ b;_EXIT_status=$?; rsync -rlDzR -essh parallel-server3:././aa\\\<\\\${\\\#}\\\"\\\ b ./; exit $_EXIT_status; +### Test if remote login shell is csh +ssh csh@localhost 'eval `echo $SHELL | grep -E "/(t)?csh" > /dev/null && echo setenv PARALLEL_SEQ '$PARALLEL_SEQ'\; setenv PARALLEL_PID '$PARALLEL_PID' || echo PARALLEL_SEQ='$PARALLEL_SEQ'\;export PARALLEL_SEQ\;PARALLEL_PID='$PARALLEL_PID'\;export PARALLEL_PID` ;' echo\ \$PARALLEL_PID\ \$PARALLEL_SEQ\ a\|\ wc\ -w; +3 +ssh csh@localhost 'eval `echo $SHELL | grep -E "/(t)?csh" > /dev/null && echo setenv PARALLEL_SEQ '$PARALLEL_SEQ'\; setenv PARALLEL_PID '$PARALLEL_PID' || echo PARALLEL_SEQ='$PARALLEL_SEQ'\;export PARALLEL_SEQ\;PARALLEL_PID='$PARALLEL_PID'\;export PARALLEL_PID` ;' echo\ \$PARALLEL_PID\ \$PARALLEL_SEQ\ b\|\ wc\ -w; +3 +ssh csh@localhost 'eval `echo $SHELL | grep -E "/(t)?csh" > /dev/null && echo setenv PARALLEL_SEQ '$PARALLEL_SEQ'\; setenv PARALLEL_PID '$PARALLEL_PID' || echo PARALLEL_SEQ='$PARALLEL_SEQ'\;export PARALLEL_SEQ\;PARALLEL_PID='$PARALLEL_PID'\;export PARALLEL_PID` ;' echo\ \$PARALLEL_PID\ \$PARALLEL_SEQ\ c\|\ wc\ -w; +3 ### Test {} multiple times in different commands echo 1 2 3 4 5 6 7 8 9 10 ; echo 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10