Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] docs: clarify `_arguments -A` behaviour
- X-seq: zsh-workers 53646
- From: dana <dana@xxxxxxx>
- To: "Oliver Kiddle" <opk@xxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: [PATCH] docs: clarify `_arguments -A` behaviour
- Date: Tue, 20 May 2025 19:25:01 -0500
- Archived-at: <https://zsh.org/workers/53646>
- Feedback-id: i9be146f9:Fastmail
- In-reply-to: <56012-1747779088.064972@O7xK.Wmet.0Pf8>
- List-id: <zsh-workers.zsh.org>
- References: <62649e67-48e7-4868-abf2-a47c6cdf9d74@app.fastmail.com> <56012-1747779088.064972@O7xK.Wmet.0Pf8>
On Tue 20 May 2025, at 17:11, Oliver Kiddle wrote:
> Saying it is "ignored" could imply a wider effect.
it is ambiguous on its own, yeah. i kept it because the _arguments
documentation uses that word in other places (like -S) with seemingly
the same implications. but tried to clarify
On Tue 20 May 2025, at 17:11, Oliver Kiddle wrote:
> Perhaps it is simpler if we try to keep things in terms of how different
> command-line parsers work. The traditional Unix convention was that the
> first non-option argument would terminate the options. The -A option
> helps to identify this first non-option argument by using a pattern.
normally a program halts entirely when it encounters an undefined
option, it doesn't just terminate option parsing as if it were a normal
operand (nor skip over it). why would _arguments not do the same? why
continue to complete options that the program won't accept because it's
been given erroneous input?
the main reasons i can think of are (1) our completion functions often
have an imperfect understanding of what is erroneous input, and (2) the
user might not actually care what the program will do, they just want
to complete the options to see the descriptions or to pass them to
another tool or whatever else
i thought the bit about it being annoying would be a succinct way to
encapsulate that question + those answers
do you just disagree with the wording/characterisation of that part? i
can drop it if that's all (attached). or you'd prefer another direction
entirely? or you think it's already as clear as it needs to be?
dana
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 06b08cc72..d9f151871 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -3743,11 +3743,12 @@ argument, and the `tt(-)tt(-)' is considered to be neither.
)
item(tt(-A) var(pat))(
Do not complete options after the first non-option
-argument on the line. var(pat) is a pattern matching
-all strings which are not to be taken as arguments. For example, to make
-tt(_arguments) stop completing options after the first normal argument, but
-ignoring all strings starting with a hyphen even if they are not described
-by one of the var(optspec)s, the form is `tt(-A "-*")'.
+argument on the line. Any such argument that matches var(pat)
+is ignored (as if it didn't appear on the line) until another
+non-option argument is encountered that doesn't match it. This
+is most often used in the form `tt(-A "-*")' to prevent the
+function from treating an option not described by one of the
+var(optspec)s as a non-option argument.
)
item(tt(-O) var(name))(
Pass the elements of the array var(name) as arguments to functions called to
Messages sorted by:
Reverse Date,
Date,
Thread,
Author