-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Expand globs in arguments on Windows? #1096
Comments
My first reaction is that this shouldn't be done by Click, although it should be possible to subclass |
IMHO such behavior would have to be completely disabled on non-Windows systems. Maybe the least strange/error-prone solution would be to have a |
The Windows convention that it is every program's job to make up for cmd not having globs, yes. "Annoying thing that every cli app has to do" seems like it falls within click's scope.
I believe in traditional Windows globbing the metacharacters are
As @ThiefMaster notes, you'd only enable enable this on Windows. But what if someone is using mingw bash on Windows? Well, then you might double-expand, just like every other traditional Windows cli program would in the same situation.
That would be an interesting option for
I'm not really familiar with how click uses envvars. As a Unix user I would expect |
Agree.
It would be less efficient, but the easiest way would be to always pass values through expanduser and glob first. Is there a way to signal that something glob-like isn't a glob, like single quotes on Unix? One last thing I thought of. What happens when using |
I'm not sure. In Windows, quote handling is also done in process (basically you just get a raw command line string and are free to do whatever with it), so in principle you could use quotes to disable globbing for specific arguments. But in Python, the quote handling happens early in interpreter startup, so you can't see them in Python's glob module lets you use
I don't know enough about click and |
Hello, I came here from the Black project, because running
I think leaning on Python's
To reiterate njsmith, this would have to be a Windows-only feature. The * and ? characters are illegal to have in files on Windows anyway (I assume this is an NTFS thing.)
Nah. This isn't a Windows command line idiom. It'd be easier to leave it unimplemented, given that Anyway, my comments mostly reiterate what njsmith said. I'd just like to shed more light on this issue because "wildcards don't work on Windows" seems like a pretty big deal for every program that uses Click. |
Thinking about this again, processing should only happen in So the solution for this is to add a call to |
This comment has been minimized.
This comment has been minimized.
Note that I think we should also call |
I'm using a variadic
Path
argument:When I run
myprogram.py *.txt
, then on unix of course it works, because the shell expands on the glob. But on Windows, glob expansion is the responsibility of the program being invoked, and click doesn't appear to do it – even in a case like this where it has all the information needed to tell that glob expansion is appropriate. And click kind of has to do it, because click wants to validate the paths, and this has to happen after glob expansion – if I pass*.txt
, it saysError: Invalid value for "paths": Path "*.txt" does not exist.
, and my code doesn't even get invoked, so I can't even fix up the globs myself, except by disabling all of click's validation and then doing it all myself.The text was updated successfully, but these errors were encountered: