2 ms·
Yo, author here. You are very much correct and I 100% agree with you, I have updated the first example to include a snippet where a proper env-var is used to s
by refp 2mo ago
Yo, author here.
You are very much correct and I 100% agree with you, I have updated the first example to include a snippet where a proper env-var is used to show of the automatic diagnostic.
Thanks for your feedback, much much appreciated!
- deleted 2mo ago[deleted]
- wolletd 2mo agoFor a short-lived script, the `${1:?missing argument}` stuff may be useful, but usually, I want to print some longer usage or help text in the error case. I usually go with something like this: set -eu function eusage() { echo "Usage: $0 <input-file> <output-file>" >&2 echo "Error: $@" >&2 exit 1 } infile=${1:-}; shift || eusage "Missing input filename" outfile=${1:-}; shift || eusage "Missing output filename" The `${1:-}` in this case evaluates to an empty string if `$1` is not set, but `shift` fails when there is no argument to remove.