[SOLVED] zparseopts - How to pass multiple argument to an option
by blueray from LinuxQuestions.org on (#54NDW)
I am using zsh 5.4.2. The function that is causing issue is:
Code:function zp () {
zparseopts -E -watch:=o_watch -show=o_show
echo "show : $o_show"
echo "watch : $o_watch"
}Output:
Code:$ zp --show --watch "Watching"
show : --show
watch : --watch Watching
$ zp --watch --show
show :
watch : --watch --showYou can see that, If I do not pass a value to --watch (which's argument is mandatory) then it takes the next option in this case --show as the argument. It should actually show an error like zp:zparseopts:1: missing argument for option: -watch
Why is --watch taking --show as an argument instead of throwing an error.


Code:function zp () {
zparseopts -E -watch:=o_watch -show=o_show
echo "show : $o_show"
echo "watch : $o_watch"
}Output:
Code:$ zp --show --watch "Watching"
show : --show
watch : --watch Watching
$ zp --watch --show
show :
watch : --watch --showYou can see that, If I do not pass a value to --watch (which's argument is mandatory) then it takes the next option in this case --show as the argument. It should actually show an error like zp:zparseopts:1: missing argument for option: -watch
Why is --watch taking --show as an argument instead of throwing an error.