Other Help Topics :: Cond statements, BASH



Or even more tech: both [ and test are actually the same common shell builtin, atleast bash and ash have it. So when invoked just like that, [ something or test something, they are the same thing, but as binaries, /usr/bin/[ something, they would be different ;)
When struggling with bash syntax it is often helpful to preuse existing bash scripts, i.e., /etc/init.d/knoppix-autoconfig and/or /etc/init.d/dsl.config
I'm always impressed by the level of expertise on this board.  Although I'm not sure where someone learns about binaries related to
"[" vs. "test" , I'm duly impressed and enlightened.  I'm studying knoppix-autoconfig right now with vim, where spacing is clear.

Quote
Although I'm not sure where someone learns about binaries related to
"[" vs. "test"
I can't speak for others, but in my case it comes from constant poking and prodding at things to see what color they bleed.

When it comes to "[" specifically, I just thought it was very odd to see that character listed as a filename when i did "ls /usr/bin", so I had to find out what was up.  This is kind of an unusual situation because "man [" and "[ --help" don't work. However, "/usr/bin/[ --help" does work:
Code Sample
/usr/bin/[ --help
Usage: test EXPRESSION
 or:  [ EXPRESSION ]
 or:  [ OPTION
Exit with the status determined by EXPRESSION.

In DSL, it looks like [ is a symlink to test.  However, as curaga pointed out, it's also a bash/ash built-in, so removing it could save a couple KB -- unless something else requires it? (and put it in gnu-utils, if it isn't already in there?)

Quote
This is kind of an unusual situation because "man [" and "[ --help" don't work.
I'd guess that the shell would try to parse that... or try to use the built-in function (hence the use of the full path)

Next Page...
original here.