mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-04 22:51:42 +02:00
44087: _getconf: Complete options, config variables on more systems
This commit is contained in:
parent
d669a9a045
commit
3efacdbacf
2 changed files with 85 additions and 33 deletions
|
@ -1,5 +1,8 @@
|
||||||
2019-02-27 dana <dana@dana.is>
|
2019-02-27 dana <dana@dana.is>
|
||||||
|
|
||||||
|
* 44087: Completion/Unix/Command/_getconf: Complete options,
|
||||||
|
complete config variables on more systems
|
||||||
|
|
||||||
* 44090 (re: 44085): Completion/Unix/Type/_remote_files: Don't
|
* 44090 (re: 44085): Completion/Unix/Type/_remote_files: Don't
|
||||||
set QUOTING_STYLE -- syntax incompatible with some shells
|
set QUOTING_STYLE -- syntax incompatible with some shells
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#compdef getconf
|
#compdef getconf
|
||||||
|
|
||||||
local expl ret=1
|
local variant list_cmd ret=1
|
||||||
|
local -a context expl line state state_descr args
|
||||||
|
local -A opt_args
|
||||||
|
|
||||||
local -a syskeys posixkeys confkeys pathkeys1 pathkeys2 allkeys mykeys restkeys
|
local -a syskeys posixkeys confkeys pathkeys1 pathkeys2 allkeys mykeys restkeys
|
||||||
syskeys=(ARG_MAX BC_BASE_MAX BC_DIM_MAX BC_SCALE_MAX
|
syskeys=(ARG_MAX BC_BASE_MAX BC_DIM_MAX BC_SCALE_MAX
|
||||||
|
@ -23,38 +25,85 @@ pathkeys1=(PIPE_BUF _POSIX_CHOWN_RESTRICTED
|
||||||
pathkeys2=(LINK_MAX MAX_CANON MAX_INPUT NAME_MAX PATH_MAX PIPE_BUF)
|
pathkeys2=(LINK_MAX MAX_CANON MAX_INPUT NAME_MAX PATH_MAX PIPE_BUF)
|
||||||
mykeys=($syskeys $posixkeys $confkeys $pathkeys1 $pathkeys2)
|
mykeys=($syskeys $posixkeys $confkeys $pathkeys1 $pathkeys2)
|
||||||
|
|
||||||
if [[ CURRENT -eq 2 ]]; then
|
if _pick_variant -r variant gnu='(Free Soft|GLIBC)' $OSTYPE --version; then
|
||||||
_tags syswideconfig pathconfig standardsconfig confstring restconfig
|
# GNU getconf doesn't use getopt(3), strangely
|
||||||
|
args+=(
|
||||||
|
'(: * -)--help[display help information]'
|
||||||
|
'(: * -)--version[display version information]'
|
||||||
|
'(1 -)-a[display all configuration variables and their values]'
|
||||||
|
'(-)-v[specify programming environment]: :->env'
|
||||||
|
)
|
||||||
|
: ${list_cmd:='$words[1] -a'}
|
||||||
|
|
||||||
allkeys=(${${(f)"$(getconf -a 2>/dev/null)"}%%[: ]*})
|
|
||||||
restkeys=(${allkeys:|mykeys})
|
|
||||||
|
|
||||||
while _tags; do
|
|
||||||
_requested -V syswideconfig expl 'systemwide configuration variables' \
|
|
||||||
compadd -S '' $syskeys && ret=0
|
|
||||||
|
|
||||||
_requested -V standardsconfig \
|
|
||||||
expl 'system-standards configuration variables' \
|
|
||||||
compadd -S '' $posixkeys && ret=0
|
|
||||||
|
|
||||||
_requested -V confstring \
|
|
||||||
expl 'configuration-dependent string variables' \
|
|
||||||
compadd -S '' $confkeys && ret=0
|
|
||||||
|
|
||||||
_requested pathconfig &&
|
|
||||||
while _next_label -V pathconfig expl 'system path configuration variables'; do
|
|
||||||
compadd "$expl[@]" -S '' $pathkeys1 && ret=0
|
|
||||||
compadd "$expl[@]" -S ' ' $pathkeys2 && ret=0
|
|
||||||
done
|
|
||||||
|
|
||||||
if (( ${#restkeys} )); then
|
|
||||||
_requested -V restconfig \
|
|
||||||
expl 'remaining unclassified configuration variables' \
|
|
||||||
compadd -S '' $restkeys && ret=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
(( ret )) || return 0
|
|
||||||
done
|
|
||||||
else
|
else
|
||||||
_files -/
|
[[ $variant == (netbsd*|solaris*) ]] && {
|
||||||
|
args+=( '(1 -)-a[display all configuration variables and their values]' )
|
||||||
|
: ${list_cmd:='$words[1] -a'}
|
||||||
|
}
|
||||||
|
|
||||||
|
[[ $variant == openbsd* ]] && {
|
||||||
|
args+=(
|
||||||
|
'(: - *)-l[display all system (non-path) configuration variables]'
|
||||||
|
'(: - *)-L[display all path configuration variables]'
|
||||||
|
)
|
||||||
|
: ${list_cmd:='$words[1] -l; $words[1] -L'}
|
||||||
|
}
|
||||||
|
|
||||||
|
[[ $variant == netbsd* ]] ||
|
||||||
|
args+=( '(-)-v+[specify programming environment]: :->env' )
|
||||||
|
|
||||||
|
# This is a bit silly, but actually pretty accurate, where available
|
||||||
|
: ${list_cmd:='
|
||||||
|
command strings -- ${${(Q)words[1]}:c} |
|
||||||
|
LC_ALL=C GREP_OPTIONS= command grep -xE \
|
||||||
|
"_*[A-Z][A-Z0-9_]*_[A-Z0-9_]*|NZERO|PATH|[A-Z]+(BITS|SIZE)"
|
||||||
|
'}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
_arguments -S -A '-*' : $args '1: :->var' '2: :_files' && ret=0
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
env)
|
||||||
|
_wanted environments expl 'programming environment' compadd - \
|
||||||
|
POSIX_V{6,7}_ILP32_OFF32 \
|
||||||
|
POSIX_V{6,7}_ILP32_OFFBIG \
|
||||||
|
POSIX_V{6,7}_LP64_OFF64 \
|
||||||
|
POSIX_V{6,7}_LPBIG_OFFBIG \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
var)
|
||||||
|
_tags syswideconfig pathconfig standardsconfig confstring restconfig
|
||||||
|
|
||||||
|
allkeys=(${${(f)"$( _call_program variables $list_cmd )"}%%[=:[:space:]]*})
|
||||||
|
restkeys=(${allkeys:|mykeys})
|
||||||
|
|
||||||
|
while _tags; do
|
||||||
|
_requested -V syswideconfig expl 'system-wide configuration variable' \
|
||||||
|
compadd -S '' $syskeys && ret=0
|
||||||
|
|
||||||
|
_requested -V standardsconfig \
|
||||||
|
expl 'system-standards configuration variable' \
|
||||||
|
compadd -S '' $posixkeys && ret=0
|
||||||
|
|
||||||
|
_requested -V confstring \
|
||||||
|
expl 'configuration-dependent string variable' \
|
||||||
|
compadd -S '' $confkeys && ret=0
|
||||||
|
|
||||||
|
_requested pathconfig &&
|
||||||
|
while _next_label -V pathconfig expl 'system path configuration variable'; do
|
||||||
|
compadd "$expl[@]" -S '' $pathkeys1 && ret=0
|
||||||
|
compadd "$expl[@]" -S ' ' $pathkeys2 && ret=0
|
||||||
|
done
|
||||||
|
|
||||||
|
if (( ${#restkeys} )); then
|
||||||
|
_requested -V restconfig \
|
||||||
|
expl 'remaining unclassified configuration variable' \
|
||||||
|
compadd -S '' $restkeys && ret=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
(( ret )) || break
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
Loading…
Reference in a new issue