On Sun, 19 Sep 2021 22:41:24 +0100 Richard Lewis
<richard.lewis.deb...@googlemail.com> wrote:

> giving two arguments including one that is not a package shows there is a 
> syntax error somewhere around line 378:
>
> $ apt-show-versions apt whatever
> apt:amd64/bullseye 2.2.4 uptodate
> Use of uninitialized value $arch in concatenation (.) or string at 
> /usr/bin/apt-show-versions line 378.
> Use of uninitialized value $arch in hash element at 
> /usr/bin/apt-show-versions line 381.
> Use of uninitialized value $arch in hash element at 
> /usr/bin/apt-show-versions line 393.
> whatever: not installed
>

I think this is because at the start of print_package,  the 'if' at
359 always succeeds if we had more than one package on the command
line, (mode will !=MODE_SINGLE) but
if the package was invalid, $archname is not defined.

It doesnt make sense to call print_package_internal unless $archname
has been set, so i wonder if line 359 should be
- deleted
- replaced with if($archname)
-replaced with "if(mode!=$MODE_SINGLE&& $archname"
-something else
?

356    if ($archname and ! defined $apackages->{$pkgname}{$archname})
{
357        printf("%s not available for architecture %s\n", $pkgname,
$archname);
358    } elsif (! defined $pkgs->{$pkgname}) {
359        if ($mode != $MODE_SINGLE || $archname) {
360            print_package_internal($pkgname, $archname)
361        } elsif (keys(%{$apackages->{$pkgname}})) {
362            my $archlist = "";
363            foreach my $a (sort keys(%{$apackages->{$pkgname}})) {
364                print_package_internal($pkgname, $a);
365                $archlist .= ($archlist ? ", $a" : "$a");
366            }
367        } else {
368            printf("%s not installed (not available)\n", $pkgname);
369        }
370    } else {
371        foreach my $arch ($archname or sort
keys(%{{map{$_=>1}(keys(%{$apackages->{$pkgname}}),

Reply via email to