1

Why can't my getopt work when no options given?

view story
linux-howto

http://unix.stackexchange.com – I have this code - #getoptDemo.sh usage() { echo "usage: <command> options:<w|l|h>" } while getopts wlh: option do case $option in (w) name='1';; (l) name='2';; (h) name='3';; (*) usage exit;; esac done print 'hi'$name When I run bash getoptDemos.sh (without the option) it prints hi instead of calling the function usage. It calls usage when options other than w, h and l are given. Then can't it work when no options are (HowTos)