Skip to content

Commit

Permalink
Improve/simplify Fatal error: Missing *expected* "$val" to "$opt"
Browse files Browse the repository at this point in the history
Fatal errors should be precisely coded, not "obfuscated".

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
  • Loading branch information
TinCanTech committed Apr 28, 2022
1 parent 526bedf commit 35a63c8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions easytls
Original file line number Diff line number Diff line change
Expand Up @@ -9300,7 +9300,14 @@ main () {
# Separate option from value:
opt="${1%%=*}"
val="${1#*=}"
empty_ok="" # Empty values are not allowed unless excepted

# Empty values are not allowed unless expected
unset -v is_empty empty_ok
# eg: '--batch'
[ "$opt" = "$val" ] && is_empty=1
# eg: '--pki-dir='
[ "$val" ] || is_empty=1


case "${opt}" in

Expand Down Expand Up @@ -9385,10 +9392,10 @@ main () {
esac

# fatal error when no value was provided
if [ -z "${empty_ok}" ] && { [ "${val}" = "${1}" ] || [ -z "${val}" ]; }
then
fatal_opt "Missing value to option: ${opt}"
if [ "$is_empty" ]; then
[ "$empty_ok" ] || die "Missing value to option: $opt"
fi

shift
done

Expand Down

0 comments on commit 35a63c8

Please sign in to comment.