Slight glitch in /etc/cron.daily/apt-compat Ubuntu 16.04.3 in apt-1.2.24
Bug #1742378 reported by
rklemme
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
apt (Ubuntu) |
Fix Released
|
Low
|
Julian Andres Klode |
Bug Description
I accidentally stumbled across this. If in line 22 on_ac_power returns a non zero exit code the next line is never reached. Instead, the shell terminates immediately with that non zero exit code because of "set -e" in line 3. In this script it does not pose a problem because the shell is asked to exit anyway if check_power() returns non zero but it works differently than is apparently intended (concluding from the logic).
I will attach a suggest patch and a demo illustrating that the patch works as the original script seems to intend to.
To post a comment you must log in.
Produces this output:
$ sh check_power_test.sh
+ echo begin
begin
+ check_power 0
+ exit 0
+ return 0
+ check_power 1
+ exit 1
+ [ 1 -ne 1 ]
+ return 1
+ echo ignore
ignore
+ check_power 255
+ exit 255
+ [ 255 -ne 1 ]
+ return 0
+ echo end
end