zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@zsh.org>
To: Zsh workers <zsh-workers@zsh.org>
Subject: PATCH: completion after chmod -x
Date: Fri, 19 Nov 2021 16:14:35 +0100	[thread overview]
Message-ID: <11426-1637334875.215528@cINF.rQGd.ZpAn> (raw)

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


                 reply	other threads:[~2021-11-19 15:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=11426-1637334875.215528@cINF.rQGd.ZpAn \
    --to=opk@zsh.org \
    --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).