evaluate_strictness()
{
[["$2" =~ ^-(-(config|command|help|version)$|[chv]) ]] && die "You have passed '$2' as a value of argument '$1', which makes it look like that you have omitted the actual value, since '$2' is an option accepted by this script. This is considered a fatal error."
}
Make the script fail if setopt -o errexit is set, as if the comparison is "false" the return value is also false -> and bash kill the process.
One solution could be to negate the comparison:
evaluate_strictness()
{
[[ ! "$2" =~ ^-(-(config|command|help|version)$|[chv]) ]] || die "You have passed '$2' as a value of argument '$1', which makes it look like that you have omitted the actual value, since '$2' is an option accepted by this script. This is considered a fatal error."
}
Or add a return 0 after the [[]], like
evaluate_strictness()
{
[["$2" =~ ^-(-(config|command|help|version)$|[chv]) ]] && die "You have passed '$2' as a value of argument '$1', which makes it look like that you have omitted the actual value, since '$2' is an option accepted by this script. This is considered a fatal error."
return 0
}
The following statement
Make the script fail if
setopt -o errexit
is set, as if the comparison is "false" the return value is also false -> and bash kill the process. One solution could be to negate the comparison:Or add a return 0 after the
[[]]
, likeevaluate_strictness() { [["$2" =~ ^-(-(config|command|help|version)$|[chv]) ]] && die "You have passed '$2' as a value of argument '$1', which makes it look like that you have omitted the actual value, since '$2' is an option accepted by this script. This is considered a fatal error." return 0 }