--option-parsing: useful for completion

This commit is contained in:
boyska 2012-01-23 03:34:25 +01:00
parent 4a3d59c3a4
commit 72b44a84f6

View File

@ -1648,7 +1648,20 @@ main() {
done
local -a oldstar
oldstar=($argv)
zparseopts -M -E -D -Adiscardme ${every_opts}
#### detect early: useful for --optiion-parsing
zparseopts -M -D -Adiscardme ${every_opts}
if [[ -n ${(k)discardme[--option-parsing]} ]]; then
echo $1
if [[ -n "$1" ]]; then
return 1
fi
return 0
fi
unset discardme
if ! zparseopts -M -E -D -Adiscardme ${every_opts}; then
error "error parsing"
return 127
fi
unset discardme
subcommand=$1
if [[ -z $subcommand ]]; then
@ -1783,8 +1796,9 @@ EOF
# {{{ RUNTIME
check_bin
main $@
if [[ $? != 0 ]]; then #this "if" seems useless, but avoid source tomb source from exiting
exit $?
ret=$?
if [[ $ret != 0 ]]; then #this "if" seems useless, but avoid source tomb source from exiting
exit $ret
fi
# }}}