On Tue, Oct 19, 2021 at 10:42:04AM +0900, Yuichiro NAITO wrote:
> Following patch changes pkg_add to return a error code,
> if a package name is wrong.
> 
> diff --git a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
> b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
> index 7a968cbf05d..39bee874ff1 100644
> --- a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
> +++ b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
> @@ -403,12 +403,13 @@ sub check_root
>  sub choose_location
>  {
>       my ($state, $name, $list, $is_quirks) = @_;
>       if (@$list == 0) {
>               if (!$is_quirks) {
>                       $state->errsay("Can't find #1", $name);
> +                     $state->{bad}++;
>                       $state->run_quirks(
>                           sub {
>                               my $quirks = shift;
>                               $quirks->filter_obsolete([$name], $state);
>                           });
>               }
> 
> Is it OK?
> 
> On 10/18/21 16:53, Yuichiro NAITO wrote:
> > Hi, I have a question about exit status of pkg_add command.
> > 
> > When I wrote a package install script which included typo in a package name
> > (of course it's my fault), the script didn't stop in spite of `set -e`.
> > 
> > Because pkg_add command returns 0 even if a package name is wrong.
> > Is this exit status intended or design policy of pkg_add command?
> > 
> > If not, I want a error status getting returned.
> > It will save my time to look for a typo or similar bug.
> > 
> > I can't see 'EXIT STATUS' section in the pkg_add manual of OpenBSD 7.0.
> > So, I e-mailed this question.
> > 

Basically, there are a few traps in pkg_add wrt exit status.

The main trap is that making pkg_add error out in cases it didn't requires
testing, because various automated situations that already exist might fail.

I will most probably fix that one, assuming there is no fallout.

Reply via email to