Gentoo Archives: gentoo-user

From: "Beau E. Cox" <beaucox@×××××××××.com>
To: gentoo-user@l.g.o
Cc: Robert Persson <ireneshusband@××××××××.uk>
Subject: Re: [gentoo-user] /usr/bin/test doesn't seem to do anything
Date: Sat, 28 Jan 2006 08:05:29
Message-Id: 200601272157.32001.beaucox@hawaii.rr.com
In Reply to: Re: [gentoo-user] /usr/bin/test doesn't seem to do anything by Robert Persson
1 On Friday 27 January 2006 09:43 pm, Robert Persson wrote:
2 > On Thursday 26 January 2006 16:22 Richard Fish was like:
3 > > test doesn't output anything...it indicates success/failure with the
4 > > exit code.  
5 >
6 > ...
7 >
8 > > As others have said though, watch out for the 'test' command built-in
9 > > to many shells, as the behavior there is defined by the shell.
10 > > Generally though, /usr/bin/test and bash test should work the same....
11 >
12 > It turns out that I was mistaken and the script was in fact invoking the
13 > bash built-in test (the /usr/bin/test stuff was my overactive imagination).
14 >
15 > /usr/bin/test is still weird, as Eric Bliss said, because it doesn't print
16 > help and version info the way the manpage says it should.
17 >
18 > A difference between the two tests is that, for /usr/bin/test, a non-zero
19 > exit status means false, whereas bash test resolves to a non-zero value
20 > when true.
21
22 Not true. Both exit with $? == 0 on success. Try this script:
23
24 #!/bin/sh
25
26 test -d /etc
27 echo "test -d /etc : $?"
28 /usr/bin/test -d /etc
29 echo "/usr/bin/test -d /etc : $?"
30
31 test -d /etcx
32 echo "test -d /etcx : $?"
33 /usr/bin/test -d /etcx
34 echo "/usr/bin/test -d /etcx : $?"
35
36 which outputs:
37
38 test -d /etc : 0
39 /usr/bin/test -d /etc : 0
40 test -d /etcx : 1
41 /usr/bin/test -d /etcx : 1
42
43
44 >
45 > Haven't had time to take another look at the bash script I was wrestling
46 > with. So still not sure whether bash test is being weird as well.
47 >
48 >
49 > --
50 > Robert Persson
51 >
52 > Conspiracy Bears:
53 > Once upon a time there were lots of conspiracy bears...
54
55 --
56 Aloha => Beau;
57
58
59 --
60 gentoo-user@g.o mailing list