* [gentoo-user] /usr/bin/test doesn't seem to do anything
@ 2006-01-26 23:35 Robert Persson
2006-01-26 23:56 ` Zac Medico
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Robert Persson @ 2006-01-26 23:35 UTC (permalink / raw
To: gentoo-user
Someone was kind enough to send me a script that calls /usr/bin/test. When the
script didn't work I realised that test was behaving strangely. Basically it
doesn't seem to return anything.
For instance "test -f /usr/bin/test" doesn't display any output.
Nor does "test --help".
Nor "test --version".
The version I am using is from sys-apps/coreutils-5.2.1-r6 .
It's very hard to do a google search for anything to do with troubleshooting a
program called "test". Anyone know what is going on here?
Thanks
Robert
--
Robert Persson
ireneshusband@fastmail.fm
YahooMessenger:ireneshusband
Conspiracy Bears:
Once upon a time there were lots of conspiracy bears...
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] /usr/bin/test doesn't seem to do anything
2006-01-26 23:35 [gentoo-user] /usr/bin/test doesn't seem to do anything Robert Persson
@ 2006-01-26 23:56 ` Zac Medico
2006-01-27 0:03 ` Eric Bliss
2006-01-27 0:22 ` Richard Fish
2 siblings, 0 replies; 6+ messages in thread
From: Zac Medico @ 2006-01-26 23:56 UTC (permalink / raw
To: gentoo-user
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robert Persson wrote:
> Someone was kind enough to send me a script that calls /usr/bin/test. When the
> script didn't work I realised that test was behaving strangely. Basically it
> doesn't seem to return anything.
>
> For instance "test -f /usr/bin/test" doesn't display any output.
>
> Nor does "test --help".
>
> Nor "test --version".
>
> The version I am using is from sys-apps/coreutils-5.2.1-r6 .
>
> It's very hard to do a google search for anything to do with troubleshooting a
> program called "test". Anyone know what is going on here?
Well, you could start with `man test`. However, test is also a bash builtin (try `type test`) so you may want to consult the bash info manual instead (try `info bash`).
Zac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFD2WGn/ejvha5XGaMRAkjoAJ9LICiZO1ZUDB/RDVR+lVSCz5xu8ACg7bKq
Y56PjDpGuymg/Pp9icaqX+Y=
=SxG/
-----END PGP SIGNATURE-----
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] /usr/bin/test doesn't seem to do anything
2006-01-26 23:35 [gentoo-user] /usr/bin/test doesn't seem to do anything Robert Persson
2006-01-26 23:56 ` Zac Medico
@ 2006-01-27 0:03 ` Eric Bliss
2006-01-27 0:22 ` Richard Fish
2 siblings, 0 replies; 6+ messages in thread
From: Eric Bliss @ 2006-01-27 0:03 UTC (permalink / raw
To: gentoo-user
On Thursday 26 January 2006 03:35 pm, Robert Persson wrote:
> Someone was kind enough to send me a script that calls /usr/bin/test. When
the
> script didn't work I realised that test was behaving strangely. Basically it
> doesn't seem to return anything.
>
> For instance "test -f /usr/bin/test" doesn't display any output.
>
> Nor does "test --help".
>
> Nor "test --version".
>
> The version I am using is from sys-apps/coreutils-5.2.1-r6 .
>
> It's very hard to do a google search for anything to do with troubleshooting
a
> program called "test". Anyone know what is going on here?
>
try "info coreutils test". Seems there may also be a "test" command built
into the shell. In addition, test itself doesn't seem like it prints out
information, but simply exits with an error code of 0, 1, or 2. It also said
something about using an unmatched square bracket when trying to use the
--help and --version options.
In general, it just looks kind of weird.
--
Eric Bliss
systems design and integration,
CreativeCow.Net
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] /usr/bin/test doesn't seem to do anything
2006-01-26 23:35 [gentoo-user] /usr/bin/test doesn't seem to do anything Robert Persson
2006-01-26 23:56 ` Zac Medico
2006-01-27 0:03 ` Eric Bliss
@ 2006-01-27 0:22 ` Richard Fish
2006-01-28 7:43 ` Robert Persson
2 siblings, 1 reply; 6+ messages in thread
From: Richard Fish @ 2006-01-27 0:22 UTC (permalink / raw
To: gentoo-user
On 1/26/06, Robert Persson <ireneshusband@yahoo.co.uk> wrote:
> Someone was kind enough to send me a script that calls /usr/bin/test. When the
> script didn't work I realised that test was behaving strangely. Basically it
> doesn't seem to return anything.
test doesn't output anything...it indicates success/failure with the
exit code. Try the following test.sh script:
#!/bin/bash
/usr/bin/test "$@"
rc=$?
if test "$rc" -eq 0; then
echo "'test $@' was successful"
else
echo "'test $@' failed with code $rc"
fi
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....
-Richard
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] /usr/bin/test doesn't seem to do anything
2006-01-27 0:22 ` Richard Fish
@ 2006-01-28 7:43 ` Robert Persson
2006-01-28 7:57 ` Beau E. Cox
0 siblings, 1 reply; 6+ messages in thread
From: Robert Persson @ 2006-01-28 7:43 UTC (permalink / raw
To: gentoo-user
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.
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...
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] /usr/bin/test doesn't seem to do anything
2006-01-28 7:43 ` Robert Persson
@ 2006-01-28 7:57 ` Beau E. Cox
0 siblings, 0 replies; 6+ messages in thread
From: Beau E. Cox @ 2006-01-28 7:57 UTC (permalink / raw
To: gentoo-user; +Cc: Robert Persson
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-01-28 8:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-26 23:35 [gentoo-user] /usr/bin/test doesn't seem to do anything Robert Persson
2006-01-26 23:56 ` Zac Medico
2006-01-27 0:03 ` Eric Bliss
2006-01-27 0:22 ` Richard Fish
2006-01-28 7:43 ` Robert Persson
2006-01-28 7:57 ` Beau E. Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox