-
-
Save polds/ec764ee9438e1b9d0246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
my $ssh="/usr/bin/ssh"; | |
my $mosh="/usr/bin/mosh"; | |
my $host; | |
my $unsupported=0; | |
for (my $i=0; $i <= $#ARGV; $i++) { | |
if ($ARGV[$i] =~ /^-/) { | |
$ssh .= " \"$ARGV[$i]\""; | |
if ( grep { /$ARGV[$i]/ } ("-A","-C","-D","-e","-f","-g","-L","-M","-N","-n","-R","-V","-W","-w","-X","-Y") ) { | |
print "mosh does not support ssh's \"$ARGV[$i]\" option.\n"; | |
$unsupported=1; | |
} | |
if ( grep { /$ARGV[$i]/ } ("-b","-c","-D","-e","-F","-I","-i","-L","-l","-m","-O","-o","-p","-R","-S","-W","-w") ) { | |
$ssh .= " \"$ARGV[$i+1]\""; | |
$i++; | |
} | |
} else { | |
$host=$ARGV[$i]; | |
} | |
} | |
my $res=system("$mosh --ssh='$ssh' $host"); | |
if ( $unsupported || $res == 1280 || $res == 32512) { | |
print "Falling back to ssh...\n"; | |
exec("$ssh $host"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added a
$res == 32512
check.