1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-07-10 16:31:27 +02:00
zsh/Completion/Unix/Command/_getopt
dana f59025f849 unposted: Fix util-linux variant detection in _getopt
This had been broken all along for the actual util-linux getopt; i think the
'enhanced' text comes from the original author's version, which Homebrew was
still using when the function was written
2022-04-26 21:54:29 -05:00

29 lines
1.3 KiB
Text

#compdef getopt ggetopt
local -a args aopts
# @todo BusyBox getopt is borrowed straight from util-linux, so they're nearly
# identical, but not quite: BusyBox doesn't have -h and -V and often doesn't
# support long options. So possibly this could be more accurate
if _pick_variant busybox=BusyBox util-linux='(enhanced|util-linux)' unix --version; then
args=(
'(-a --alternative)'{-a,--alternative}'[allow long options with single -]'
'(: -)'{-h,--help}'[display help information]'
'*'{-l+,--longoptions=}'[specify long options]:long options'
'(-n --name)'{-n+,--name=}'[specify program name]:program name'
'(1 -o --options)'{-o+,--options=}'[specify short options]:short options'
'(-q --quiet)'{-q,--quiet}'[suppress getopt(3) error messages]'
'(-Q --quiet-output)'{-Q,--quiet-output}'[suppress normal output]'
'(-s --shell)'{-s+,--shell=}'[specify shell quoting conventions]:shell:(bash csh tcsh sh)'
'(: -)'{-T,--test}'[test for enhanced getopt]'
'(-u --unquoted)'{-u,--unquoted}'[do not quote output]'
'(: -)'{-V,--version}'[display version information]'
'(-o --options)1: :_guard "^-*" "short options"'
'*:argument'
)
[[ -n $POSIXLY_CORRECT ]] && aopts+=( -A '-*' )
else
args=( '1:short options' '*:argument' )
fi
_arguments -s -S $aopts : $args