Here is my example file:!/bin/bash# argument-one# Is first argument missing?# First method[[ $1 ==  ]] && echo Usage: $(basename $0) filename; exit 1# Second method# filename=${1?Usage: $(basename $0) filename}In the above script, I get a clean message Usage: argument-one filenamewhen I run the above script with no arguments; and it exits cleanly.However, if I comment out line 7 and uncomment line 10, I get this error message when the program exits:./argument-one: line 10: 5: Usage: argument-one filenameThis message suggests that there is something wrong with the program that triggered it to exit, when in fact, it was actually an invocation with no arguments, which is a usage issue.But line 10 is preferable because it is more terse and also assigns a variable if available.My question is: How might I retain only the message part and filter out or disable the ./argument-one: line 10: 5: part of the usage message?Thanks.
Parameter substitution and error messages: suppressing line numbers etc
bash;variable substitution;parameter