4 ms·
fish shell has been burned in the few places it strictly implements POSIX. The most vivid example is test, aka /bin/[. POSIX specifies that, if test is invoked
by ridiculous_fish 6y ago
fish shell has been burned in the few places it strictly implements POSIX.
The most vivid example is test, aka /bin/[. POSIX specifies that, if test is invoked with one argument, you must "Exit true (0) if $1 is not null; otherwise, exit false" [1].
This means that `test --help` is forbidden from printing any help. It means that `test -d $argv` expands to `test -d` if $argv is empty, which then must "succeed" because "-d" is not null. It bites users over and over again [2].
Implementing this POSIX piece has resulted in more headaches, not fewer. I regret implementing a POSIX-conformant test, I wish I had just picked mostly-compatible but also-sane semantics.
1: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/t...
2: https://stackoverflow.com/questions/29635083/fish-shell-check-if-argument-is-provided-for-function/34221866 https://stackoverflow.com/questions/29635083/fish-shell-chec...
- a1369209993 6y ago> It means that `test -d $argv` expands to `test -d` if $argv is empty, which then must "succeed" because "-d" is not null. It bites users over and over again [2]. To be fair, while the POSIX behaviour is obviously wrong, using `$argv` on a bourne-style shell[0] is also wrong; that should be either `test -d "$argv"` or (if I recall the syntax correctly) `test -d "${argv[@]}"` if you actually intended argv to be a list rather than a single directory ("argv" suggests the former, but `test -d X` only accepts a single argument). 0: more specifically, a shell that does word splitting at the wrong place (after parameter expansion)