>From: "Cloyce D. Spradling" <cloyce+xunix at headgear.org> >On Mon, May 23, 2005 at 08:20:20PM -0500, David Gilden wrote: > >: what is '[' > >It is a handy shorthand for 'test'. > >In a shell script, when you see > > if [ "$FOO" = bar ]; then > >you probably thought that it was all internal. Not so! The above is >equivalent to test (and [) are bash and ksh builtins. Try copying /bin/test to something else and removing the original. (Copy rather than move in case the shells cache the inode). test still works, in bash & ksh anyway. Don't forget to mv the file back. At 00:35 -0700 24/5/05, x-unix-request at listserver.themacintoshguy.com wrote: >It's not the shell... it's test. All the shell wants is > >if <program> > >It's test that wants the space. I wouldn't expect > > test"$FOO" = bar > >to work. Would you? The space seems reasonable to me in this context. No, it's the shell. The shell needs to split the line up to work out which is the command. It splits the line on the characters in $IFS (default is space, tab & return) and some of its own metacharacters. '[' as a command needs a delimiter both sides of it for the shell to use it as such whether or not an 'if' is used. >From: John Harrold <jmh17 at pitt.edu> >Subject: Re: [X-Unix] /bin strange directory ?? >To: "A place to discuss Mac OS X from the perspective of the command > line." <x-unix at listserver.themacintoshguy.com> >Message-ID: <20050524125835.GH20530 at sage.che.pitt.edu> >Content-Type: text/plain; charset=us-ascii > >Sometime in May Alexandre Gauthier assaulted the keyboard and produced: > >| For random informative bits, [ is a shell builtin on bash. At least on >| my Linux workstation, my iBook is too far away for me to check, and i'm >| lazy. > >Are you sure about this? I used to think it was built in also, but then I >never actually looked for [. The command 'which \[' shows me that it is in >/usr/bin/... I shall be a monkey's uncle. That's just 'which' confusing the issue. It's only searching PATH. David -- David Ledger - Freelance Unix Sysadmin in the UK. Chair of HPUX SysAdmin SIG of hpUG technical user group (www.hpug.org.uk) david.ledger at ivdcs.co.uk www.ivdcs.co.uk