Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: completion after chmod -x



The changes I made in 49499 related to _arguments' -A option causes
arguments matching the pattern but not corresponding to one of the known
listed options to be ignored and not counted as one of the normal
arguments.

That change does have the potential to cause issues for a command that
allows for a normal argument that matches the option pattern. An example
of that is chmod where, e.g. chmod -x is a short form of chmod a-x.
Fortunately in the case of chmod it is fairly easy to handle this by
using a more explicit pattern with -A.

For GNU chmod, where we never used -A, the change had no effect. That
does highlight the fact that without -A, unknown options continue to
be counted amongst the normal arguments. This is perhaps something of
an inconsistency. I'm reluctant to make a change to bring them in line
without first allowing more time for odd cases such as chmod to surface.
Oddities are probably more common on something old like chmod which
was designed with hand-coded C option parsing whereas most people now
just use whatever option parsing libraries come with their programming
language.

Oliver

diff --git a/Completion/Unix/Command/_chmod b/Completion/Unix/Command/_chmod
index 3f6db7e91..42e3fa63b 100644
--- a/Completion/Unix/Command/_chmod
+++ b/Completion/Unix/Command/_chmod
@@ -1,7 +1,10 @@
 #compdef chmod gchmod zf_chmod
 
 local curcontext="$curcontext" state line expl ret=1 variant
-local -a args privs aopts=( -A '-*' )
+local -a args privs aopts
+
+# usual -* pattern picks up valid non-options, e.g. -x which is like a-x
+aopts=( -A '-[^gorstuwxX]*' )
 
 args=( '*: :->files' '1: :_file_modes' )
 




Messages sorted by: Reverse Date, Date, Thread, Author