-
Notifications
You must be signed in to change notification settings - Fork 17.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flag: it is not reasonable not to support "-flag x" for boolean flags. #22961
Comments
If boolean flags always consumed a value, then you would need to write If boolean flags only consumed boolean values, then the number of positional parameters in of Non-boolean flags always consume a value, so there is no ambiguity. |
Working as in intended, and as documented in the package-level docs. And as said above, the non-boolean flags don't have the problem because they always consume a value. |
Yes, a boolean flag can consume zero or one value. If it is the last flag without consuming a value. It can be followed by a And how is this problem related to shell expansions. Could you provide a real example? |
If users are aware of the expansion (users really should), it is not surprising and hazardous. |
|
I'm sorry, I think if btw, the |
"Is it a shell standard?"
|
could you provide more examples? As I have mentioned above, for the Shell commands even allow flags appear after non-flag arguments, but Go flags will ignore such flags. |
Sorry, this is incorrect. Your GNU program reorders the argument vector at runtime and puts your options before your operands. Your expectation of this feature to be ubiquitous doesn't make it the standard, in fact: I would consider it harmful. http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html Guideline 9: |
Ok. But argument vector reordering is NOT the core of the issue. What problem does the exception the The standard package shouldn't try to fix the mistakes made by users. In other words, users should be aware of shell expansions. |
My point is the exception made by the |
@dotaheor As you say, the flag package is not going to change. What change to the documentation do you suggest? The current flag package documentation does not mention shell expansion. |
What do the two lines mean?
My last comment shows my suggestion for the doc change. |
@dotaheor I take it to mean that * might expand to any of Perhaps the docs could mention the difference between The Go docs should help Go developers. The shell docs (and possibly the authors of an app) should help end users. For example, most end users are used to flags being booleans, whose non-existence means |
Then why did you mention it?
That's incredibly pedantic I agree with the idea that the package shouldn't mention shell expansion. Some supported platforms don't expand
I contest. That's hideous, and it's unfortunate The confusion that I often clarify when approached with the question: "Why are Go flags so ugly" is the similarity of The fact that |
The reason I submitted this issue is that I was confused by the two lines
I totally had not any ideas on what the two lines want to express. The stackoverflow answer might not be a good answer. I think the word "file" is not essential in the doc. My new suggestion for the doc changes are:
I still think the exception breaks the beauty of consistency. |
Change https://golang.org/cl/82015 mentions this issue: |
Updates #22961 Change-Id: Ib2f41aefb4f6470598d8637611da5491156ea840 Reviewed-on: https://go-review.googlesource.com/82015 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
The
flag
standard package saysIt is not convinced that this exception is only made for boolean flags.
Why isn't it also made for number and string flags?
It is the same situation for number and string flags.
IMO, it is totally unnecessary to make this exception.
Shell expansions are common and normal.
Go packages shouldn't do anything to avoid some special shell expansions.
[update]
What the package documentation should do is to just let users pay attention to shell expansions.
The text was updated successfully, but these errors were encountered: