zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: completion after chmod -x
@ 2021-11-19 15:14 Oliver Kiddle
  0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2021-11-19 15:14 UTC (permalink / raw)
  To: Zsh workers

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' )
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-19 15:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19 15:14 PATCH: completion after chmod -x Oliver Kiddle

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).