Hacker News new | ask | show | jobs
by yjftsjthsd-h 935 days ago
That does work if you call it as `test`; just a quirk of faking shell syntax in an external binary I think.
1 comments

I was halfway expecting /bin/[ -> /bin/test, but that did pass the smell test since the ] is required, so it couldn't just be symlink
It 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.
There'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
Are norg and ungron similar to wobble and wibble?