about summary refs log tree commit diff
path: root/Completion/Unix/Command/_mkdir
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2017-08-29 02:28:10 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2017-09-04 14:05:24 +0000
commit1e536747aee3d39d7e960add67f19fcf6e9ee284 (patch)
tree7eba263379bdf93bc44726b2ea1b413683d3edce /Completion/Unix/Command/_mkdir
parent2c4e5c4acb5964581eae28c5fda2526c6fc6237b (diff)
downloadzsh-1e536747aee3d39d7e960add67f19fcf6e9ee284.tar.gz
zsh-1e536747aee3d39d7e960add67f19fcf6e9ee284.tar.xz
zsh-1e536747aee3d39d7e960add67f19fcf6e9ee284.zip
41621: _mkdir: Honour the 'command' and 'builtin' precommand modifiers.
Diffstat (limited to 'Completion/Unix/Command/_mkdir')
-rw-r--r--Completion/Unix/Command/_mkdir25
1 files changed, 12 insertions, 13 deletions
diff --git a/Completion/Unix/Command/_mkdir b/Completion/Unix/Command/_mkdir
index afa9cc1f8..2850b405d 100644
--- a/Completion/Unix/Command/_mkdir
+++ b/Completion/Unix/Command/_mkdir
@@ -9,22 +9,21 @@ args=(
   '(-)*: :->directories'
 )
 
-_pick_variant -r variant gnu=gnu zsh='\(eval\)' $OSTYPE --help
 # 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.
-
-# I currently don't know of any way to find out what precommands are present on
-# the line. The variant should be modified like this once a way is found out:
-
-# if [[ $variant == zsh ]]; then
-#   if [[ $precommand = *command* ]]; then
-#     _mkdir_command () { command mkdir "$@" }
-#     _pick_variant -c _mkdir_command -r variant gnu=gnu unix --help
-#   fi
-# elif [[ $precommand = *builtin* ]]; then
-#   variant=zsh
-# fi
+# 
+# $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.
 
 case $variant in
   gnu|freebsd*|dragonfly*)