* [PATCH] _chmod: use $line[1] instead of $words[2] to access the mode
@ 2014-01-05 12:52 Jun T.
2014-01-05 18:16 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Jun T. @ 2014-01-05 12:52 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] _chmod: use $line[1] instead of $words[2] to access the mode
2014-01-05 12:52 [PATCH] _chmod: use $line[1] instead of $words[2] to access the mode Jun T.
@ 2014-01-05 18:16 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2014-01-05 18:16 UTC (permalink / raw)
To: zsh-workers
On Sun, 5 Jan 2014 21:52:56 +0900
"Jun T." <takimoto-j@kba.biglobe.ne.jp> wrote:
> 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'.
This is quite hard to verify for sure, since that parameter emerges from
the comparguments builtin in Src/Zle/computil.c after some quite major
engineering works, but it certainly looks plausible indepdendently of
your testing --- my reading is that everything that happens in the code
is associated with arguments that map onto something specified by the
_arguments call, which don't include the command name that triggered
completion. I've submitted a change.
pws
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-05 18:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-05 12:52 [PATCH] _chmod: use $line[1] instead of $words[2] to access the mode Jun T.
2014-01-05 18:16 ` Peter Stephenson
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).