From: espie Date: Sun, 21 May 2023 13:44:21 +0000 (+0000) Subject: "fix" for 5.36: pass the possible option value as an extra param X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=88617dfe2347b2b16281c0612ca81ff2bc76d434;p=openbsd "fix" for 5.36: pass the possible option value as an extra param instead of defined/undefined, so that the code sub is called with the right number of parameters. --- diff --git a/usr.sbin/pkg_add/OpenBSD/Getopt.pm b/usr.sbin/pkg_add/OpenBSD/Getopt.pm index f382c3fa09e..98713830664 100644 --- a/usr.sbin/pkg_add/OpenBSD/Getopt.pm +++ b/usr.sbin/pkg_add/OpenBSD/Getopt.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Getopt.pm,v 1.14 2023/05/19 07:25:16 espie Exp $ +# $OpenBSD: Getopt.pm,v 1.15 2023/05/21 13:44:21 espie Exp $ # # Copyright (c) 2006 Marc Espie # @@ -29,17 +29,17 @@ our @EXPORT = qw(getopts); sub handle_option { - my ($opt, $hash, $params) = @_; + my ($opt, $hash, @params) = @_; if (defined $hash->{$opt} and ref($hash->{$opt}) eq 'CODE') { - &{$hash->{$opt}}($params); + &{$hash->{$opt}}(@params); } else { no strict "refs"; no strict "vars"; - if (defined $params) { - ${"opt_$opt"} = $params; - $hash->{$opt} = $params; + if (@params > 0) { + ${"opt_$opt"} = $params[0]; + $hash->{$opt} = $params[0]; } else { ${"opt_$opt"}++; $hash->{$opt}++;