Skip to content

Commit

Permalink
[mosh] Use entries from the configuration file
Browse files Browse the repository at this point in the history
mobile-shell#431

Initialize options from the configuration file if not present on the
command line.

Signed-off-by: Earl Chew <[email protected]>
  • Loading branch information
earlchew committed Apr 7, 2018
1 parent 69f0e60 commit 373871c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions scripts/mosh.pl
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,54 @@ sub predict_check {

my @bind_arguments;
my $userhost = shift;
my $host = (split(/@/, $userhost))[-1];
my @command = @ARGV;
my %hostconfig = %{$configFile->lookupHost($host)};

my %configFileOptions = (
'Client' => \$client,
'Server' => \$server,
'Predict' => \$predict,
'Port' => \$port_request,
'Family' => \$family,
'Ssh' => \@ssh,
'TermInit=?' => \$term_init );

foreach my $key (keys %configFileOptions) {
my @words = split(/=/, $key);
my $name = $words[0];
my $kind = $words[1];
my $var = $configFileOptions{$key};

my $vartype = ref($var);

$kind = '' unless (defined($kind));

if ($vartype eq 'ARRAY') {
unless (@{$var}) {
@{$var} = $configFile->lookupOption($name);
}

} elsif ($vartype eq 'SCALAR') {
unless (defined ${$var}) {

${$var} = $configFile->lookupOption($name);

if (defined ${$var}) {
if ($kind eq '?') {
my $yes = uc(${$var}) eq 'YES';
my $no = uc(${$var}) eq 'NO';

die "Configuration $name must have value yes or no\n"
unless ($yes or $no);

${$var} = $yes;
}
}
}
}

}

$client = 'mosh-client' unless defined($client);
$server = 'mosh-server' unless defined($server);
Expand Down

0 comments on commit 373871c

Please sign in to comment.