about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Martin <phy1729@gmail.com>2019-03-19 22:09:25 -0500
committerMatthew Martin <phy1729@gmail.com>2019-03-21 22:04:55 -0500
commit9b267ff1ebd02177613c25ba8e032fdcc4b8d349 (patch)
tree3b2be6efa9792e15dbf78fcd3e534958b33b9413
parent8e4566e5365e4fbefec55a7c28432dd241987ea6 (diff)
downloadzsh-9b267ff1ebd02177613c25ba8e032fdcc4b8d349.tar.gz
zsh-9b267ff1ebd02177613c25ba8e032fdcc4b8d349.tar.xz
zsh-9b267ff1ebd02177613c25ba8e032fdcc4b8d349.zip
44149: _mkdir, _stat: Use _pick_variant -b
-rw-r--r--ChangeLog3
-rw-r--r--Completion/Unix/Command/_mkdir16
-rw-r--r--Completion/Unix/Command/_stat16
3 files changed, 9 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 172e63d85..b645c492d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@
 
 2019-03-21  Matthew Martin  <phy1729@gmail.com>
 
+	* 44149: Completion/Unix/Command/_mkdir,
+	Completion/Unix/Command/_stat: Use _pick_variant -b.
+
 	* 44144: Completion/Zsh/Command/_builtin: Append "builtin" to
 	precommands.
 
diff --git a/Completion/Unix/Command/_mkdir b/Completion/Unix/Command/_mkdir
index e4308c304..58d1b8f48 100644
--- a/Completion/Unix/Command/_mkdir
+++ b/Completion/Unix/Command/_mkdir
@@ -9,21 +9,7 @@ args=(
   '(-)*: :->directories'
 )
 
-# It can still happen that there is a precommand command or builtin in the line.
-# In such cases, the variant has to be modified suitably, after further checking
-# the variant of the _command_ mkdir.
-# 
-# $precommands is defined in _main_complete
-if (( ${+precommands[(r)command]} )); then
-  _mkdir_command () { command mkdir "$@" }
-  _pick_variant -c _mkdir_command -r variant gnu=gnu unix --help
-  unfunction _mkdir_command
-elif (( ${+precommands[(r)builtin]} )) || (( ${+builtins[mkdir]} )) || [[ "$(type -w mkdir)" == "*: builtin" ]]; then
-  variant=zsh
-else
-  _pick_variant -r variant gnu=gnu zsh='\(eval\)' $OSTYPE --help
-fi
-# Now $variant is set.
+_pick_variant -r variant -b zsh gnu=gnu $OSTYPE --help
 
 case $variant in
   gnu|freebsd*|dragonfly*|darwin*)
diff --git a/Completion/Unix/Command/_stat b/Completion/Unix/Command/_stat
index 2e84d6bf0..03b4552de 100644
--- a/Completion/Unix/Command/_stat
+++ b/Completion/Unix/Command/_stat
@@ -6,20 +6,14 @@
 #   Dragonfly by parsing the output of `lsof -N`, but it's not available by
 #   default — is there another way?
 
-local expl variant precmd ret=1
+local expl variant ret=1
 local -a context line state state_descr args aopts=( -A '-*' )
 local -A opt_args
 
-if [[ $service == zstat ]] || [[ $precommands[-1] == builtin ]]; then
-  variant=zsh
-else
-  [[ $precommands[-1] == command ]] && precmd=command
-  _pick_variant -c "${precmd:+$precmd }${words[1]}" -r variant \
-    gnu='Free Soft' zsh='no files given' unix --version
-fi
+_pick_variant -r variant -b zsh gnu='Free Soft' $OSTYPE --version
 
-case $OSTYPE-$variant in
-  *-zsh)
+case $variant in
+  zsh)
     args=(
       "(-H)-A[assign the results to array, don't print]:array variable:_parameters -g '*array*'"
       - set1
@@ -43,7 +37,7 @@ case $OSTYPE-$variant in
       '-l[list stat types]'
     )
     ;;
-  *-gnu)
+  gnu)
     aopts=( )
     args=(
       '*: :_files'