[X-Unix] A little shell scripting help

Doug McNutt douglist at macnauchtan.com
Mon Oct 3 18:57:34 PDT 2005


At 14:46 -0700 10/3/05, Philip J Robar wrote:
>The '[' is the test command, which tests your expression. The result  of the test is then evaluated by the if. Note that the spaces after  the '[' and before the ']' are required.

And that's the reason I use tcsh.  If you look at /bin you'll find an executable file named "[". It is actually a link to the UNIX tool "test" The space is the normal thing required between a command and its arguments.

I spent hours staring at the bash book from O'Reilly where it does say the space is required but it's extremely easy to overlook it.  The space before the "]" is needed just so bash can ignore it.

And while we're at it there are two copies of bash one of which is named sh. In other UNICES they are links to the same code but in Mac OS neXt there are two copies. Some say it's because hard links in HFS+ are a pretty serious hack that is slow.
-- 

--> From the U S of A, the only socialist country that refuses to admit it. <--


More information about the X-Unix mailing list