-
Notifications
You must be signed in to change notification settings - Fork 76
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
[Feature request] add is_literal(pattern) #72
Comments
Could you describe how you want to use this function? |
Basically I want to do two different things depending on whether the path contains globs or not. It's useful for example for copy operation (like |
Sorry, I'm not following. Could you spell it out for me? |
Sure! This is a simplification of the actual operation. I want to copy some files. User provides source and dest paths. If the user specifies a simple source path it's just a normal copy:
If the user specifies a glob path then the previous copy approach is no longer possible, so I strip the source path until the first glob and then append that to the dest path.
Thus I have different logic paths depending on whether the user provides a literal path or a glob path. This is true even if the glob only resolves to a single path, so I can't just resolve it first. |
I am also interested in a similar feature. Basically I want users to be able to specify list of files using glob patterns. I do not want an error if a glob pattern yields an empty list of files. However I want to produce an error if the glob pattern is infact a plain file name and the file is missing. Thus if would be nice if there was a function which determined if a string was in fact making use of any glob pattern feature or if it was just a plain file name. |
I would also like this. It would be helpful for implementing "argv globbing" of the form that I see in many other programs (on Windows, where globbing is done by the app, not by the shell). This works as follows:
The important point is that in a directory containing only a file |
The use case I had (mentioned above by @mre) was to determine whether the pattern looks like a glob or plain path. I ended up doing: let is_glob = glob::Pattern::escape(value) != value; |
It would be really helpful to have a function that tells you whether the input pattern contains any globs.
Basically a version of this that ignores escaped characters:
The text was updated successfully, but these errors were encountered: