Sujet : Re: Take that, Microsoft!
De : sebastian (at) *nospam* here.com.invalid (Sebastian Wells)
Groupes : comp.os.linux.advocacyDate : 25. May 2024, 08:46:53
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v2s1gt$2okjl$2@dont-email.me>
References : 1 2 3 4 5 6
User-Agent : Pan/0.154 (Izium; 517acf4)
On Fri, 24 May 2024 17:35:09 -0000 (UTC), candycanearter07 wrote:
Chris Ahlstrom <OFeem1987@teleworm.us> wrote at 12:39 this Friday (GMT):
But both can be used by other shells. The files /usr/bin/test and
/usr/bin/[ are different sizes, but doing "man \[" brings up test(1).
Good to know, I suppose.
That made me curious enough to dig. On MacOS, /bin/[ and /bin/test are
hardlinked together.
"dpkg-query" says that both [ and test are provided by coreutils, but
coreutils has a src/test.c, and src/lbracket.c for the other program.
src/lbracket.c is very simple:
#define LBRACKET 1 #include "test.c"
The reason for the difference seems to be that GNU wanted to have --help
and --version options, but POSIX only allows [ to print anything in
response to those options, while "test" has to exit silently.
MacOS also handles these arguments differently depending on if it's
/bin/[ or /bin/test, with [ printing an error message (and no help)
instead of returning silently.