DEV Community

Chuan Miao
Chuan Miao

Posted on

Answer: Check existence of input argument in a Bash shell script

In some cases you need to check whether the user passed an argument to the script and if not, fall back to a default value. Like in the script below:

scale=${2:-1}
emulator @$1 -scale $scale

Here if the user hasn't passed scale as a 2nd parameter, I launch Android emulator…

Top comments (0)