Package: java-common
Version: 0.72
Severity: normal

Dear Maintainer,

The update-java-alternatives shell script, which using the "list" action 
("--list" / "-l"), ends with a call to the "do_list" function, which ends with:

[ -n "$verbose" ] && egrep "$which" $i

Therefore the exit status of this "foo && bar" becomes the return status of the 
function itself, and since there is no explicit "exit", it also becomes the 
exit status of the script itself.
As a result, this listing operation, which, as far as I can tell, should almost 
always exit with a 0 status, often exits with a 1 status.
This can either occur if that grep founds nothing or, more frequently it seems, 
if the "verbose" variable is empty.
In other words, I got a different exit status depending on whether verbosity 
("--verbose") was turned on or not, which is a surprising result for any 
executable indeed.

  $ update-java-alternatives --verbose --list &> /dev/null; echo $?
0
  $ update-java-alternatives --list &> /dev/null; echo $?
1

In my humble opinion, the "do_list" function should end with an explicit 
"return 0".

Here are my currently listed Java versions:

java-1.11.0-openjdk-amd64      1111       /usr/lib/jvm/java-1.11.0-openjdk-amd64

* What led up to the situation?

Random crashes in a Dockerfile involving update-java-alternatives.

* What exactly did you do (or not do) that was effective (or ineffective)?

Tried with and without "--verbose"; used "|| true"; looked up the source script.

* What was the outcome of this action?

Bypassing the exit status.

* What outcome did you expect instead?

There should be no need to bypass it.


-- System Information:
Debian Release: bullseye/sid
  APT prefers focal-updates
  APT policy: (500, 'focal-updates'), (500, 'focal-security'), (500, 'focal'), 
(100, 'focal-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.15.0-46-generic (SMP w/8 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US 
(charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

java-common depends on no packages.

java-common recommends no packages.

Versions of packages java-common suggests:
pn  default-jre  <none>

-- no debconf information

Reply via email to