Closed nkakouros closed 5 years ago
I have a question. When using bash autocomplete, there are around 4,5 commands that return '1' if no candidate for completion is found. When setting set -e
, this stops execution at the first such command. This is no problem, as the completion would anyway return nothing in the command line. But when using trap custom_function ERR
without set -e
, the commands that return 1 cause custom_function
to run as many times as there are such commands. This is bad as the user receives unexpected output when instead nothing should be printed in the command line pressing TAB. Should this PR try to 'fix' these commands as well? In my own projects, I take care of the situation in my custom_function
by searching for libexec/complete
in "${BASH_SOURCE[@]}" and doing
set -- ERR` if found.
cc: @mbland
I run my scripts with
set -euo pipefail
at the very top. I run into some unbound variables when doing so. Maybe I'll run into more as I move into using this framework. I think it is good to have default values/explicit null to make assumptions in the code clearer.On the part where I changed
:=
to:-
, I did so to avoid running the same value assignment twice.This PR is regardless of #220, but it could prove handy if #220 starts getting implemented. This PR is meant to support those users that do want the strict mode in their scripts.