News for hackers. Stuff that matters.
Re:Why is /usr/bin/test 4kiB smaller than /usr/bin/[? by superasn on Tuesday April 06, 2021 @06:27AM (#26710204)
> When you write if [ -e /etc/passwd ]; then .. that bracket is not shell syntax but just a regular command with a funny name. It’s serviced by /usr/bin/[, or (more likely) a shell builtin. This explains a lot of its surprising behavior, e.g. why it’s notoriously space sensitive: [1=2] is no more valid than ls-l/tmp.

To me this is even more interesting than the size thing. Wth seriously! It changes the way I will think of it next time I'm gonna use it.

I thought perl was a strange language with all the swearing cartoon characters, until I was introduced to bash and all the strange things like the hyphen for a default argument and what not. Writing shell scripts without stackoverflow is so hard because of all such idiosyncrasies (or maybe remanants of the past?).

Re:Why is /usr/bin/test 4kiB smaller than /usr/bin/[? by kevincox on Tuesday April 06, 2021 @09:20AM (#26711428)
And of course - has no special meaning to the shell or kernel. It is just convention that many commands treat it is a sentenal value (usually input from stdin or output to stdoht depending on the context)

The most important thing to understanding shell is that there are shell features, which have basically arbitrary parsing rules although they have some consistency, as well as commands which are parsed consistently into an argument list, but how that argument list is interpreted is completely up to the command.

Now while these may help you understand shell, they do not constitue a "good" programming language.

Re:Why is /usr/bin/test 4kiB smaller than /usr/bin/[? by colanderman on Tuesday April 06, 2021 @11:28AM (#26713026)
Took a moment to realize you were naming the symbol "-" (i.e. hyphen-minus) specifically, and not using it grammatically as an en-dash.
Re:Why is /usr/bin/test 4kiB smaller than /usr/bin/[? by Valodim on Wednesday April 07, 2021 @05:25AM (#26722271)
It's more of a historical note at this point. modern shells have a builtin for [, to avoid that fork on every single if statement.
Re:Why is /usr/bin/test 4kiB smaller than /usr/bin/[? by stevieoop on Tuesday April 06, 2021 @10:25AM (#26712130)
you might also like the fact that true is an executable. try 'man true'