Skip to content

Commit

Permalink
[mosh] Initialize options only if not provided on the command line
Browse files Browse the repository at this point in the history
mobile-shell#431

Declare option variables as undef, and only provide a default value
if options were not provided on the command line in preparation for
obtaining values from a configuration file.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>
  • Loading branch information
earlchew committed Apr 7, 2018
1 parent fca128e commit 69f0e60
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions scripts/mosh.pl
Original file line number Diff line number Diff line change
Expand Up @@ -435,31 +435,32 @@ BEGIN

my $configFile = ConfigFile->new([ '~', '.mosh', 'config' ]);

my $client = 'mosh-client';
my $server = 'mosh-server';
my $client = undef;
my $server = undef;

my $predict = undef;

my $overwrite = 0;

my $bind_ip = undef;

my $use_remote_ip = 'proxy';
my $use_remote_ip = undef;

my $family = undef;

my $family = 'prefer-inet';
my $port_request = undef;
my %port_setting = (
firewall_port => 0,
server_port => 0,
port_range => 0 );

my @ssh = ('ssh');
my @ssh = ();

my $term_init = 1;
my $term_init = undef;

my $localhost = undef;

my $ssh_pty = 1;
my $ssh_pty = undef;

my $help = undef;
my $version = undef;
Expand Down Expand Up @@ -630,6 +631,14 @@ sub predict_check {
my $userhost = shift;
my @command = @ARGV;

$client = 'mosh-client' unless defined($client);
$server = 'mosh-server' unless defined($server);
@ssh = ('ssh') unless @ssh;
$term_init = 1 unless defined($term_init);
$ssh_pty = 1 unless defined($ssh_pty);
$family = 'prefer-inet' unless defined($family);
$use_remote_ip = 'proxy' unless defined($use_remote_ip);

if ( defined $predict ) {
predict_check( $predict, 0 );
} elsif ( defined $ENV{ 'MOSH_PREDICTION_DISPLAY' } ) {
Expand Down

0 comments on commit 69f0e60

Please sign in to comment.