On Friday 27 January 2006 09:43 pm, Robert Persson wrote:
> On Thursday 26 January 2006 16:22 Richard Fish was like:
> > test doesn't output anything...it indicates success/failure with the
> > exit code.  
>
> ...
>
> > As others have said though, watch out for the 'test' command built-in
> > to many shells, as the behavior there is defined by the shell.
> > Generally though, /usr/bin/test and bash test should work the same....
>
> It turns out that I was mistaken and the script was in fact invoking the
> bash built-in test (the /usr/bin/test stuff was my overactive imagination).
>
> /usr/bin/test is still weird, as Eric Bliss said, because it doesn't print
> help and version info the way the manpage says it should.
>
> A difference between the two tests is that, for /usr/bin/test, a non-zero
> exit status means false, whereas bash test resolves to a non-zero value
> when true.

Not true. Both exit with $? == 0 on success. Try this script:

#!/bin/sh

test -d /etc
echo "test -d /etc : $?"
/usr/bin/test -d /etc
echo "/usr/bin/test -d /etc : $?"

test -d /etcx
echo "test -d /etcx : $?"
/usr/bin/test -d /etcx
echo "/usr/bin/test -d /etcx : $?"

which outputs:

test -d /etc : 0
/usr/bin/test -d /etc : 0
test -d /etcx : 1
/usr/bin/test -d /etcx : 1


>
> Haven't had time to take another look at the bash script I was wrestling
> with. So still not sure whether bash test is being weird as well.
>
>
> --
> Robert Persson
>
> Conspiracy Bears:
> Once upon a time there were lots of conspiracy bears...

-- 
Aloha => Beau;


-- 
gentoo-user@gentoo.org mailing list

Reply via email to