What is the most idiomatic way in Bash to test if no positional parameters are given? There are so many ways to check this, I wonder if there is one preferred way.
S
If you want it to be an error to have no positional parameters:
: ${@?no positional parameters}
will print "no positional parameters" to standard error (and exit a non-interactive shell) if $@
is unset.
Otherwise, I'm not aware of any better options than one of the various methods of checking if $#
is 0.