parallel: --sslogin with , => use \, or ,, instead.

This commit is contained in:
Ole Tange 2022-06-12 19:41:33 +02:00
parent 5535b7cbeb
commit a91ba03bac
4 changed files with 24 additions and 1 deletions

View file

@ -2654,7 +2654,7 @@ sub check_invalid_option_combinations() {
sub init_globals() {
# Defaults:
$Global::version = 20220605;
$Global::version = 20220607;
$Global::progname = 'parallel';
$::name = "GNU Parallel";
$Global::infinity = 2**31;
@ -4583,7 +4583,15 @@ sub parse_sshlogin() {
if(not @Global::sshlogin) { @Global::sshlogin = (":"); }
for my $sshlogin (@Global::sshlogin) {
# Split up -S sshlogin,sshlogin
# Parse ,, and \, as , but do not split on that
# -S "ssh -J jump1,,jump2 host1,host2" =>
# ssh -J jump1,jump2 host1
# host2
# Protect \, and ,, as \0
$sshlogin =~ s/\\,|,,/\0/g;
for my $s (split /,|\n/, $sshlogin) {
# Replace \0 => ,
$s =~ s/\0/,/g;
if ($s eq ".." or $s eq "-") {
# This may add to @Global::sshlogin - possibly bug
read_sshloginfile(expand_slf_shorthand($s));

View file

@ -3040,6 +3040,9 @@ The sshlogin '-' is special, too, it read sshlogins from stdin
To specify more sshlogins separate the sshlogins by comma, newline (in
the same string), or repeat the options multiple times.
GNU B<parallel> splits on , (comma) so if your sshlogin contains ,
(comma) you need to replace it with \, or ,,
For examples: see B<--sshloginfile>.
The remote host must have GNU B<parallel> installed.

View file

@ -18,6 +18,14 @@ echo TODO
EOF
par_sshlogin_with_comma() {
echo "### --sshlogin with \,"
parallel -S 'ssh -J lo\,localhost 127.0.0.1' echo ::: OK
echo "### --sshlogin with ,,"
parallel -S 'ssh -J lo,,localhost 127.0.0.1' echo ::: OK
}
par_sshpass_with_password() {
echo '### sshpass'
echo OK | parallel -S "sshpass -p $withpassword ssh withpassword@lo:22" echo

View file

@ -93,6 +93,10 @@ par_ssh_ssh aspire
par_ssh_ssh OK
par_ssh_ssh aspire
par_ssh_ssh OK
par_sshlogin_with_comma ### --sshlogin with \,
par_sshlogin_with_comma OK
par_sshlogin_with_comma ### --sshlogin with ,,
par_sshlogin_with_comma OK
par_sshpass_with_password ### sshpass
par_sshpass_with_password OK
par_sshpass_with_password OK