diff options
author | dana <dana@dana.is> | 2018-01-03 16:13:23 -0600 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2018-01-04 00:16:43 +0100 |
commit | 1c4e7601c4b83322e8702954c2c3b8e4672026a3 (patch) | |
tree | dcc08a08daf81c0638330e65dd8469ed691b0ca7 /Completion/Unix/Type | |
parent | 5f68531b5d8b1e6262f34e91bf047909f12dfeb2 (diff) | |
download | zsh-1c4e7601c4b83322e8702954c2c3b8e4672026a3.tar.gz zsh-1c4e7601c4b83322e8702954c2c3b8e4672026a3.tar.xz zsh-1c4e7601c4b83322e8702954c2c3b8e4672026a3.zip |
42210: factor out completion of file modes and flags and handle _comp_priv_prefix for chflags
Diffstat (limited to 'Completion/Unix/Type')
-rw-r--r-- | Completion/Unix/Type/_modes | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Completion/Unix/Type/_modes b/Completion/Unix/Type/_modes new file mode 100644 index 000000000..fbe4c9363 --- /dev/null +++ b/Completion/Unix/Type/_modes @@ -0,0 +1,37 @@ +#autoload + +# Provides completion for file modes (formerly part of _chmod) + +local curcontext=$curcontext +local -a context line state state_descr copts=( "${@}" ) privs +local -A val_args + +privs=( + 'r[read]' 'w[write]' 'x[execute]' + 's[set uid/gid]' 't[sticky]' + 'X[execute only if directory or executable to another]' + "u[owner's current permissions]" + "g[group's current permissions]" + "o[others' current permissions]" +) + +[[ $OSTYPE == solaris* ]] && +privs+=( 'l[mandatory locking]' ) + +compset -P '*,' +compset -S ',*' + +if [[ -prefix [0-7] ]]; then + _message -e number 'numeric mode' +elif compset -P '[a-z]#[+-=]'; then + _values -O copts -S '' privilege $privs && return 0 +else + compset -P '*' + copts=( -S '' ) + _alternative -O copts \ + 'who:who:((a\:all u\:owner g\:group o\:others))' \ + 'operators:operator:(+ - =)' \ + && return 0 +fi + +return 1 |