The exit
command terminates
your script and passes a given return code to the shell. By tradition,
scripts should return 0 for success and 1 (or other nonzero value) on
failure. If your script doesn’t call exit
, the return code is automatically
0.
if [ $# -lt 2 ] then echo "$0 error: you must supply two arguments" exit 1 else echo "My name is $1 and I come from $2" fi exit 0 $ ./myscript Bob ./myscript error: you must supply two arguments $ echo $? 1
18.225.11.98