-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
"?" glob/wildcard considered annoying/confusing (with "-?" option) #3649
Comments
Note you can also avoid the error by quoting the string; either |
Also, I'm curious about your wording of the subject of this issue: "Fish fails to interpret some command line arguments without escapes". Fish is in fact interpreting the argument as a glob that matches any file name beginning with a hyphen and followed by exactly one character. Since you don't have any file names matching that pattern fish tells you as much. The bash behavior is to pass the literal glob to the command if it doesn't match any files. On the other hand if you had, say, a file named |
The behavior bash has here by default is what we called "passglob" in #2394. In case a file exists that matches that glob, the filename is passed - so if you had a file named "-x" in the current directory, We came to the conclusion that this is the worst possible behavior - you don't know when it's safe to use, and it leads to e.g. This can also be customized via the "failglob" or "nullglob" options. Fish's current behavior is equivalent to "nullglob" with Personally I still feel that's the right compromise. If there's anything to be done here, I'd prefer to remove the "?" glob altogether and instead find another way to generate more complicated existent filenames, since there's very little use for that one-char glob. In fact I can't find a single use of it in our codebase. That would of course be a breaking change. |
if y'all want to categorize this more accurately by updating the title, I won't complain. I wasn't sure how to accurately describe this behavior beyond what I was seeing. I was expecting the Maybe a compromise can be reached here for automatic handling where if there is a defined completion for the command to accept a |
We definitely do not want to predicate treating We might want to consider special-casing that specific glob and always treating it as a literal rather than a glob. In my three decades of using UNIX I've never seen someone create a file name matching that specific glob other than by accident. I also agree with @faho. If we could go back in time to when fish was being created we should not implement the question-mark glob. It's used so seldom it would be better to implement it via some other mechanism such as a hypothetical |
I've actually seen people recommend creating a file called "-i". For use with |
That deserves a OMFG response. Long ago when I did UNIX tech support I would sometimes mutter under my breath "step slowly away from the keyboard" when a customer did something like that. |
¯\_(ツ)_/¯ I don't mind dealing with the work-around of escaping it; so long as the shell was to inform me what i should do either way. Adding verbosity to the existing error message to explain how to correctly escape it seems like an appropriate fix here and the entire usage debate and be avoided. |
I like the idea of adding more smarts to the glob error text. Perhaps something like:
where we would only show the last part if the glob is long and contains a ? character. |
Removing the RFC label since there seems to be consensus that simply improving the error message is sufficient. |
Perhaps quoting is the best advice (for teaching a good habit when pasting strings with wildcards you may not be aware of).
|
@anordal I like that approach a lot. |
As a relatively new user of the Friendly Interactive Shell, I just want to add my support for removing this. I've been getting the error in @anordal's comment above from curl, and it took me awhile to figure out it was due to a "feature" of fish and not a bug in curl. This wildcard undoubtedly costs users a thousand times more time in annoyance/confusion than it saves the one or two people who might intentionally use it—and there's nothing "friendly" about that. If it can't be removed entirely due to legacy concerns, is there at least a way for those of us who don't want it to disable it on our individual machines? |
@cdCorey I feel with you, but
In case you might not know, we just copied the
Right, I think the biggest problem with the current message is that it's not prefixed by
Not recommended: Then you can't run others' scripts – won't be supported. |
The curl case is also broken by #3878, so removing the
|
Note: There is one case where we use "?" as a wildcard - as an argument to case '-??*' to match grouped options in type.fish (and possibly others). I feel like it would probably okay to allow this (as it's not a file-matching glob), and similar uses in |
The one thing I use |
In any case, we have an error message, and it could probably be more beginner friendly. I have 2 commits here, with this result:
RFC |
@anordal: Submit a PR, then we can play around with it. At first glance, this seems fine to me. |
This does several things. It fixes `builtin_function()` so that errors it emits are displayed. As part of doing that I've removed the unnecessary `out_err` parameter to make the interface like every other builtin. This also fixes a regression introduced by #4000 which was attempting to fix a bug introduced by #3649. Fixes #4139
@krader1961: Since we are doing fish 3.0, should we do this? I've found two uses of "?" as a wildcard character in our codebase - in the "acidhub" and "sorin" prompts, and both are used with |
@faho, I'd be okay with making "?" a non-glob character in 3.0 but we'll really need a |
One awesome benefit would be to no longer need to escape most URIs when interacting with commands like Note that ZSH has (a plugin|an option) that automatically escapes glob characters under certain conditions (pate being one of them - perhaps our bracketed paste support can now make this possible) so that the behavior is more in-line with what a sure would intuitively suggest. But that's basically dark magic in the shell. |
Well..... not quite. "&" is still an issue, so you should still get into the habit of doing that.
We have discussed doing that, but, as you say
What we have implemented, is what I like referring to as "magic paste". When you are in a single-quoted context (i.e. there's an open single-quote), anything you paste will have both E.g. enter |
I did not know that! This is quickly going to become my favorite feature. |
I always like to have a bit of data for these decisions (is any data better than no data? perhaps not) so I had a look through my shell history. In the fourteen years of history on my personal user profiles, I can see ten or so uses of |
If we did this I think we want
|
sh -c 'env HOME=$(mktemp -d) fish'
)?fish version installed (
fish --version
):fish, version 2.4.0
OS/terminal used:
Terminal.app
Fish fails to interpret the some command line arguments correctly when they use
-?
Reproduction steps
https://asciinema.org/a/duts17f0sz4npm91kfvyq0fwe
(two examples of commands that use
-?
are graphviz's dot (brew install graphviz
) and aspell (brew install aspell
) )Results
I am able to work around this by providing the command line argument as
-\?
, so that it gets properly escaped, but I feel that this should be automatically handled.The text was updated successfully, but these errors were encountered: