-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
ls: File not found exception with wildcard (expression) is not caught in Windows. #6710
Comments
Hi! It also happens in more situations. In Windows, with '?', '<', '>', ':', '|', '?', '*', new line ('\n'), and I'm assuming more ASCII non-printable characters. This is happens because a call to the Windows implementation of File::open(...) returning (unstable) InvalidFilename. In Windows AND Unix, with long filenames:
Windows:
This is more problematic. In Linux GNU coreutils, this is the result:
Which I'm not sure it's the correct way of working for Note that this is somewhat unstable territory, as InvalidFilename is itself part of unstable io_error_more (there is a ticket about it from just two weeks ago in Rust-lang community). InvalidFilename:
This means we have to differentiate the ErrorKind, and maybe expect future changes in Rust implementation. If you don't mind, I will take on this and start working on wildcard and special chars. About the filename too long, I'm not sure if it should print "File name too long" or "No such file or directory." I would like to see more takes on this. |
Hi, I'm not sure if these issues all stem from the exception being caught in the same place. |
All these issues stem from the same place (calling to And there are two more cases to consider. The first, trying to
Linux (uutils/coreutils):
Windows (uutils/coreutils):
The second, which only affects Windows, is when trying to
In Unix filesystems, only '/' char is an illegal filename char, while in Windows there are some of them ('?', '<', '>', ':', '|', '?', '*', non-printable 0-31 ASCII control characters), so illegal filenames are mostly a Windows problem, in which Rust implementation, as of right now, maps the error to About the wildcard ('*'), it should be noted that the expand functionality is solely provided by the shell, not the process itself. The shell tries to expand all folders that, for example, start with 'a' (for Also we have to have in mind that both Taking all of that into consideration, the best solution seems to be the simplest one. In other uutils/coreutils utilities, like
To maintain consistency and handle this kind of errors, the I have it changed in a branch, producing this results:
Linux:
That is should be the expected behaviour I believe. The error for Windows reserved filenames ( I will leave a PR created for this. |
Coreutils: 0.0.27 Release
Windows 11 23H2 (OS Build 22631.4169)
Debian 12
Windows:
Debian:
The text was updated successfully, but these errors were encountered: