From 21a09a14181851e931f9b2b65704044eed169fb7 Mon Sep 17 00:00:00 2001 From: dana Date: Wed, 3 Jan 2018 18:14:05 -0600 Subject: 42214: use less general names on new functions for completing file flags and modes --- Completion/Unix/Command/_chmod | 2 +- Completion/Unix/Command/_find | 2 +- Completion/Unix/Command/_mkdir | 2 +- Completion/Unix/Type/_file_modes | 37 +++++++++++++++++++++++++++++++++++++ Completion/Unix/Type/_modes | 37 ------------------------------------- 5 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 Completion/Unix/Type/_file_modes delete mode 100644 Completion/Unix/Type/_modes (limited to 'Completion/Unix') diff --git a/Completion/Unix/Command/_chmod b/Completion/Unix/Command/_chmod index 80c6f33ca..af64b9eb9 100644 --- a/Completion/Unix/Command/_chmod +++ b/Completion/Unix/Command/_chmod @@ -3,7 +3,7 @@ local curcontext="$curcontext" state line expl ret=1 local -a args privs -args=( '*: :->files' '1: :_modes' ) +args=( '*: :->files' '1: :_file_modes' ) if _pick_variant gnu=Free\ Soft unix --version; then args+=( diff --git a/Completion/Unix/Command/_find b/Completion/Unix/Command/_find index 2bfb89825..edd46ac1c 100644 --- a/Completion/Unix/Command/_find +++ b/Completion/Unix/Command/_find @@ -139,7 +139,7 @@ _arguments -C $args \ '*-nogroup' \ '*-nouser' \ '*-ok:program: _command_names -e:*\;::program arguments: _normal' \ - '*-perm: :_modes' \ + '*-perm: :_file_modes' \ '*-print' \ '*-prune' \ '*-size:file size (blocks)' \ diff --git a/Completion/Unix/Command/_mkdir b/Completion/Unix/Command/_mkdir index 830a96162..53536b01d 100644 --- a/Completion/Unix/Command/_mkdir +++ b/Completion/Unix/Command/_mkdir @@ -4,7 +4,7 @@ local curcontext="$curcontext" state line expl args variant ret=1 typeset -A opt_args args=( - '(-m --mode)'{-m,--mode=}'[set permission mode]: :_modes' + '(-m --mode)'{-m,--mode=}'[set permission mode]: :_file_modes' '(-p --parents)'{-p,--parents}'[make parent directories as needed]' '(-)*: :->directories' ) diff --git a/Completion/Unix/Type/_file_modes b/Completion/Unix/Type/_file_modes new file mode 100644 index 000000000..fbe4c9363 --- /dev/null +++ b/Completion/Unix/Type/_file_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 diff --git a/Completion/Unix/Type/_modes b/Completion/Unix/Type/_modes deleted file mode 100644 index fbe4c9363..000000000 --- a/Completion/Unix/Type/_modes +++ /dev/null @@ -1,37 +0,0 @@ -#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 -- cgit 1.4.1