matejak / argbash

Bash argument parsing code generator
Other
1.39k stars 63 forks source link

Generated argbash script throws does not handle errors when in strict mode #100

Closed EdwardOst closed 5 years ago

EdwardOst commented 5 years ago

Generated argbash script error handling fails when in strict mode with set -eou pipefail If you exercise the error path where you forget the value for the myopt1 option as shown below ./shell2layer --myopt1 --myopt2

it should print the error

You have passed '--myopt2' as a value of argument '--myopt1', which makes it look like that you have omitted the actual value, since '--myopt1' is an option accepted by this script. This is considered a fatal error.

But instead you will get line 27: $2: unbound variable

I believe the fix is just to provide an empty default for $2 in the die() function local _ret=$2:-

matejak commented 5 years ago

This has been fixed by @kamalmarhubi in #98. As it is a non-fatal bug, it will be fixed in the next release when the right time comes.

felipecrs commented 4 years ago

@matejak can you release a new patch version of Argbash? It's still missing this fix.

matejak commented 4 years ago

Yes, I will release 2.8.2 later this month.