Idiomatic way to test if no positional params are given?
问题 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. Some ways are: ((! $# )) # check if $# is 'not true' (($# == 0)) # $# is 0 [[ ! $@ ]] # $@ is unset or null 回答1: For me, the classical way is: [[ $# -eq 0 ]] 回答2: 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