Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] _mkdir, _stat: Use _pick_variant -b
- X-seq: zsh-workers 44149
- From: Matthew Martin <phy1729@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] _mkdir, _stat: Use _pick_variant -b
- Date: Wed, 20 Mar 2019 07:56:28 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=AAV6bIY8J4l05Q7ztUVF/qOorzole5GX1+6/pEziw98=; b=uHjXLH/XZp1XAUOiEic5sWWthaGSSuagoFMKtshel9qhiJUHhOFEn/tSZjkvenXkdT aAeoDQHUMjEuDvjF3Rbnc9oyohD8QK9REt0I8mzV6uNJEpKqGY+TQfTPeEX4mAlK4z+h aa1uEzH3BgAUVF22E5Cdynym6WYNg+5t/y225hZW3LBfb4u7K9MKDBunZZ3OCVPNPABD IjFcVb+rfOcvyVygX+cnZNGE86yiA5N5+bGdZzuLpxVYXTzqCx0k2MKaDU0K1JHAtVZl FuFiab84jUCCDlvOSsyAfYyF5jwIT+cYYCgugCB1ItLFRtgXYxslGAH4UHA7mR/+LAP9 k9iQ==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Remove the custom precommand parsing from _mkdir and _stat.
_calendar also inspects precommand; but since it's a function not
a builtin, -b isn't suitable.
- Matthew Martin
---
Completion/Unix/Command/_mkdir | 16 +---------------
Completion/Unix/Command/_stat | 16 +++++-----------
2 files changed, 6 insertions(+), 26 deletions(-)
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'
--
2.21.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author