Timeline for Avoiding non-zero exit code when running `ls` using multiple patterns
Current License: CC BY-SA 4.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 14, 2022 at 15:47 | history | edited | Stéphane Chazelas | CC BY-SA 4.0 |
deleted 9 characters in body
|
| Mar 6, 2022 at 19:28 | comment | added | TooTea | @ilkkachu Of course that does happen,but it only takes you by surprise the first few times and then you get used to it. It's less work to just go back and add quotes/backslashes in the 1% of situations where the wildcard happens to match something. | |
| Mar 6, 2022 at 18:48 | comment | added | ilkkachu |
@TooTea, and then you do that in a directory where someone (maybe last year's you) made a file called kernel-versions.txt, and start wondering why it doesn't work. As long as we don't have meta-information about what the program is expecting as arguments (filenames or something else), all we can do is to do it manually. (It's just one backslash there, too) Leaving the glob as-is lets you have error messages like "ls: cannot access '*.foobar': No such file or directory" which looks nice, but even that's misleading, since it hides the fact that the shell does the globbing, not ls.
|
|
| Mar 6, 2022 at 13:53 | comment | added | TooTea |
Although not everyone might like the POSIX/Bash default of passing unmatched globs through literally, I think calling it a "misfeature" is a bit strong. Of course general scripts meant to be portable should not rely on it and always quote everything not meant to be expanded, but interactively it's nice to save some keystrokes in cases like dnf upgrade kernel*.
|
|
| Mar 5, 2022 at 15:33 | history | edited | Stéphane Chazelas | CC BY-SA 4.0 |
added 1074 characters in body
|
| Mar 5, 2022 at 15:07 | vote | accept | shikhanshu | ||
| Mar 5, 2022 at 15:07 | comment | added | shikhanshu | The quality of this response is staggering! Thanks for taking the time to write such a beautifully detailed answer. Enjoyed reading it! | |
| Mar 5, 2022 at 14:41 | history | edited | Stéphane Chazelas | CC BY-SA 4.0 |
added 317 characters in body
|
| Mar 5, 2022 at 14:21 | history | answered | Stéphane Chazelas | CC BY-SA 4.0 |