manually push option arguments to array instead of using s@
By mixing s@ for --$foo-hook options and manual pushing in --hook-dir, it can happen that options get lost. Consider the following test: use Getopt::Long; my $arr = []; GetOptions( 'A=s@' => \$arr, 'B=s' => sub { push @{$arr}, $_[1]; } ); foreach my $hook (@{$arr}) { print "hook: $hook\n"; } This works fine: perl test.pl --A=a1 --B=b1 --A=a2 --B=b2 hook: a1 hook: b1 hook: a2 hook: b2 This misses b1: perl test.pl --B=b1 --A=a2 --B=b2 hook: a2 hook: b2
This commit is contained in:
parent
26af846d0a
commit
0664792cd5
1 changed files with 13 additions and 5 deletions
16
mmdebstrap
16
mmdebstrap
|
@ -4284,10 +4284,18 @@ sub main() {
|
|||
sub { push @{ $options->{noop} }, 'no-merged-usr'; },
|
||||
'force-check-gpg' =>
|
||||
sub { push @{ $options->{noop} }, 'force-check-gpg'; },
|
||||
'setup-hook=s@' => \$options->{setup_hook},
|
||||
'extract-hook=s@' => \$options->{extract_hook},
|
||||
'essential-hook=s@' => \$options->{essential_hook},
|
||||
'customize-hook=s@' => \$options->{customize_hook},
|
||||
'setup-hook=s' => sub {
|
||||
push @{ $options->{setup_hook} }, $_[1];
|
||||
},
|
||||
'extract-hook=s' => sub {
|
||||
push @{ $options->{extract_hook} }, $_[1];
|
||||
},
|
||||
'essential-hook=s' => sub {
|
||||
push @{ $options->{essential_hook} }, $_[1];
|
||||
},
|
||||
'customize-hook=s' => sub {
|
||||
push @{ $options->{customize_hook} }, $_[1];
|
||||
},
|
||||
'hook-directory=s' => sub {
|
||||
my ($opt_name, $opt_value) = @_;
|
||||
if (!-e $opt_value) {
|
||||
|
|
Loading…
Reference in a new issue