From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: [PATCH] _chmod: use $line[1] instead of $words[2] to access the mode
Date: Sun, 5 Jan 2014 21:52:56 +0900 [thread overview]
Message-ID: <91188AF3-FD51-4C2D-AB3A-8F6DE1FBF658@kba.biglobe.ne.jp> (raw)
The following completes only files which don't have write permission
by the user:
$ chmod u+w <TAB>
But with one or more options before the 'mode', e.g.,
$ chmod -v u+w <TAB>
then it completes *all* files including those which already have write
permission.
This is due to that _chmod uses $words[2] to access the 'mode' on the
command line; I think it should be $line[1].
BTW, man zshcompsys says, in the description of _arguments,
During the performance of the action the array `line' will be set to
the command name and normal arguments from the command line, i.e. the
words from the command line excluding all options and their arguments.
But it seems $line contains only the 'normal arguments', not including
the 'command name'.
diff --git a/Completion/Unix/Command/_chmod b/Completion/Unix/Command/_chmod
index 6cb310d..5d3cb2c 100644
--- a/Completion/Unix/Command/_chmod
+++ b/Completion/Unix/Command/_chmod
@@ -57,12 +57,12 @@ case "$state" in
zmodload -F zsh/stat b:zstat 2>/dev/null
typeset -i8 ref=$(zstat +mode $opt_args[--reference])
_wanted files expl file _files -g "*(-.^f${ref#??})" && ret=0
- elif [[ $words[2] = [0-7]## ]]; then
- _wanted files expl file _files -g "*(-.^f$words[2])" && ret=0
+ elif [[ $line[1] = [0-7]## ]]; then
+ _wanted files expl file _files -g "*(-.^f$line[1])" && ret=0
else
local spec who op priv
local -a specs
- for spec in ${(s:,:)words[2]}; do
+ for spec in ${(s:,:)line[1]}; do
if [[ ${spec#*[+-=]} != [rwxst]## ]]; then
_files && ret=0
return ret
next reply other threads:[~2014-01-05 13:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-05 12:52 Jun T. [this message]
2014-01-05 18:16 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=91188AF3-FD51-4C2D-AB3A-8F6DE1FBF658@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).