A simple one liner that works can be done using:
[ "$#" -ne 1 ] && ( usage && exit 1 ) || main
This breaks down to:
- test the bash variable for size of parameters $# not equals 1 (our number of sub commands)
- if true then call usage() function and exit with status 1
- else call main() function
Things to note:
- usage() can just be simple echo "$0: params"
- main can be one long script