4 ms·
That does work if you call it as `test`; just a quirk of faking shell syntax in an external binary I think.
by yjftsjthsd-h 3y ago
That does work if you call it as `test`; just a quirk of faking shell syntax in an external binary I think.
- dylan604 3y agoI was halfway expecting /bin/[ -> /bin/test, but that did pass the smell test since the ] is required, so it couldn't just be symlink
- yjftsjthsd-h 3y agoIt could have still been implemented like that in the filesystem, if the binary read the name it was executed under and modified its behavior based on that. As an extreme case, on a stock Alpine Linux system, both test and [ - along with most other core system programs - are all symlinks to a single busybox binary that reads argv[0] and acts like whatever program it's been called as. I'm actually somewhat surprised that GNU didn't do that in this case; I, too, would have expected test and [ to be some manner of link to the same program, either with identical behavior or using invocation name to decide how to behave.
- renewiltord 3y agoThere's the old $0 trick. I use that for shell scripts that share a lot of code. if [[ $0 == "norg" ]]; then gron --ungron "$@" And so on
- hibbelig 3y agoAre norg and ungron similar to wobble and wibble?