3 ms·
I like consistent and predictable rules for how wildcard arguments are expanded. There's no way that thousands of programs would all get it right if it were up
by yrro 11y ago
I like consistent and predictable rules for how wildcard arguments are expanded. There's no way that thousands of programs would all get it right if it were up to the developers themselves!
That said, it would perhaps have been nice if glob expansion would have, in some other timeline, been performed by a separate command, so that «echo 🞳» would print out a literal 🞳 character, and «glob echo 🞳🞳» would print out the result of the expansion.
glob could then accept flags to modify the rules for expansion, such as enabling the common shortcut for recursive expansion, rather than the user having to modify the behaviour of wildcard expansions by setting global variables.
- alkonaut 11y agoThis. I can't understand why it's handled at the shell level rather than at either the OS level (some Api to expand) or as a separate system tool? What happens if I make a shell that does expansion slightly diffrently to the existing shells? That can't work well? So there is already a set of rules for expansion and all shells must implement them exactly? That does sound just slightly better than the apps trying to do the same thing?
- yrro 11y agoIf programs had to use an API to expand paths then developers would screw it up. Just look at the clusterfuck that is the command prompt on Windows! In theory this applies to shell developers as well; however POSIX specifies how expansions should work, and there are far fewer shells than there are programs that those shells launch; and shells that don't conform to POSIX are less likely to find adoption because they will break user expectation.
- alkonaut 11y agoYes, I know shells are fewer than programs, but shouldn't the OS provide an implementation if something is specified by posix? Can't see the downside of at least several shells using the same OS-provided function for it.
- yrro 11y agoGNU/Linux kinda does. https://www.gnu.org/software/libc/manual/html_node/Pattern-Matching.html#Pattern-Matching https://www.gnu.org/software/libc/manual/html_node/Pattern-M... Don't know if they are commonly used by shells however.
- Ao7bei3s 11y ago> What happens if I make a shell that does expansion slightly diffrently to the existing shells? That can't work well? We have different shells with different expansions (and a myriad other differences) and it doesn't work well. In practice, the result is that people write bash scripts, not shell scripts. (Though they often don't know, and so use #!/bin/sh anyway, and so the scripts break whenever the default shell isn't bash.)