Open HaleTom opened 4 years ago
keychain
always exits with success code 0
, even on failure.
Upon errors, the script calls die()
which performs an exit 1
, so one would expect to exit with a correct exit code.
However, the problem is that initially the script uses the trap
shell builtin to cleanup some lock files when the scripts exits.
The trap
syntax to run some bash commands upon a signal delivery or on exit is: trap <action> <signal>
. To run on shell-exit the <sigspec>
should be set to 0 or EXIT
. This applies both for dash
and bash
.
However, the code apart from droplock
also issues another exit 0
that masks the previous exit code (see trap 'droplock; exit 0' 0
in the snippet above). So that is why the script always exits with a zero exit code.
Bourne shell should be able to properly return the previously specified exit code after trap
runs the given commands, so to preserve the exit code we should simply remove the exit command from the trap syntax:
- trap 'droplock; exit 0' 0
+ trap 'droplock' 0.
I have sent a patch (https://github.com/funtoo/keychain/pull/139) but the project does not seem to be actively maintained.
hello @HaleTom - if you'd like to report a bug kindly use https://bugs.funtoo.org/
you can also reach us on Discord - for more info check https://www.funtoo.org/Welcome
I was surprised to see:
Whereas:
Can
keychain
return useful exit statuses? (I note there's noEXIT STATUS
section in theman
page, also)