Refactored readArguments
This commit is contained in:
parent
b17a9b8713
commit
98bf21fc88
1 changed files with 10 additions and 9 deletions
15
gprompt.pl
15
gprompt.pl
|
@ -911,23 +911,24 @@ EOF
|
|||
|
||||
sub readArguments
|
||||
{
|
||||
printBashInit if @ARGV == 1 && $ARGV[0] eq 'init';
|
||||
return {} unless @ARGV;
|
||||
my $state = {};
|
||||
|
||||
if (@ARGV == 1 && $ARGV[0] =~ /^\d+$/) {
|
||||
if ($ARGV[0] eq 'init') {
|
||||
printBashInit; # (will exit)
|
||||
} elsif ($ARGV[0] =~ /^\d+$/) {
|
||||
# Backward compatibility
|
||||
$INPUT{rc} = $ARGV[0];
|
||||
} else {
|
||||
if (@ARGV && $ARGV[0] eq 'prevstate') {
|
||||
shift @ARGV;
|
||||
foreach my $arg (@ARGV) {
|
||||
if ($arg eq 'prevstate') {
|
||||
$state = eval $ENV{GPROMPT_STATE};
|
||||
$state = {} if $!;
|
||||
}
|
||||
foreach my $arg (@ARGV) {
|
||||
next unless $arg =~ /^([a-z]+):(.*)$/;
|
||||
} elsif ($arg =~ /^([a-z]+):(.*)$/) {
|
||||
$INPUT{$1} = $2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $state;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue