zparseopts - How to make an option (not argument of the option) mandatory
by blueray from LinuxQuestions.org on (#54NDX)
In The example bellow:
Code:function zp () {
zparseopts -E -walk:=o_walk
echo "walk: $o_walk"
}I get the follwing output.
Code:$ zp --walk "Walking"
walk : --walk Walking
$ zp --walk
zp:zparseopts:2: missing argument for option: -walk
walk :Here the argument of the option is mandatory so I am getting this error.
How can I make the option mandatory so that I must pass --walk to zp else it will throw an error.


Code:function zp () {
zparseopts -E -walk:=o_walk
echo "walk: $o_walk"
}I get the follwing output.
Code:$ zp --walk "Walking"
walk : --walk Walking
$ zp --walk
zp:zparseopts:2: missing argument for option: -walk
walk :Here the argument of the option is mandatory so I am getting this error.
How can I make the option mandatory so that I must pass --walk to zp else it will throw an error.