4 ms·
Whoa! /bin/[ as a binary looking for it's own "]" closing bracket! What a nasty syntax hack! I wonder what the motivation was for doing this rather than just
by HarHarVeryFunny 10mo ago
Whoa!
/bin/[ as a binary looking for it's own "]" closing bracket!
What a nasty syntax hack!
I wonder what the motivation was for doing this rather than just implementing test expression support directly in the shell?
I just tried and bash also accepts some other odd filenames in place of "[", so you can do:
ln -s /bin/test "-"
ln -s /bin/test "$"
And use either of these in place of "[" (assuming they are on your path). Of course they still expect the closing "]" since that requirement comes from /bin/test.
It's an interesting way to extend bash in a confusing way! You could write a "$" utility that did something else entirely, perhaps looking for a "closing $" too, then write something like:
if $ args $;
then
fi
- 1f60c 10mo agoI also love argv[--argc]. Evil genius. And it's fully legit (from the draft C standard, 5.1.2.2.1, § 2 "Program startup"): > The parameters argc and argv and the strings pointed to by the argv array shall be modifiable by the program, and retain their last-stored values between program startup and program termination. https://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf https://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf [pdf]