[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug with 'test'
From: |
Eric Blake |
Subject: |
Re: bug with 'test' |
Date: |
Thu, 08 Dec 2005 20:43:49 -0700 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
You sent mail to the obsolete bug-sh-utils; it was forwarded to the
now-current bug-coreutils list instead.
According to Adam Chou on 12/8/2005 5:27 PM:
> test -v, test --version, test -h, and test --help do not work. they just
> return me to the command line. i have tried GNU sh-utils 2.0, coreutils
> 5.2.1 and coreutils 5.0. i wasn't aware of a newer version out to try.
The latest stable version of coreutils is 5.93:
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00058.html
> other
> people on irc have confirmed that their versions also fail to output
> anything. i also specified the full path by doing /usr/bin/test but got the
> same results.
Careful - most shells have a builtin test, so "test --help" probably
invoked the shell builtin whereas "/usr/bin/test --help" invoked the
coreutils version.
Now some comments on the first reply...
According to The Wanderer on 12/8/2005 8:06 PM:
> Since I happened to have the source sitting around, I took a look, and
> apparently this is intentional for the binary named 'test'. The binary
> named '[' will react correctly to both of those options if no ']'
> argument is provided, but according to the source, 'test' is required by
> POSIX to respond to either of those options by exiting silently with
> status 1.
Almost. POSIX requires "test --help" and "[ --help ]" both to exit
silently with status 0 (success), since they are non-zero length
one-argument expressions.
>
> This would appear to me to be a bug in the documentation, in that the
> man pages for 'test' and '[' are identical (actually, on my system, the
> latter is a symlink to the former) but their behaviour differs. I'm
> not sure how best to fix it.
How so? On my system, the man page lists 5 forms for the utility:
test EXPRESSION
test
[ EXPRESSION ]
[ ]
[ OPTION
Therefore, the ONLY way to get --help or --version (the only two supported
options) is to use the spelling [, provide just one option, and omit a
trailing ].
>
> (Hmm. A possible unintended behaviour in 5.93: '[ ] --help', rather than
> exiting silently or printing the usage message, reports "missing ']'".)
>
Nope, that's not a bug. Here, you have the start of a two-argument
expression, but left off the trailing ]. According to the synopsis, you
can only use a single option when there are no other arguments, so this is
indeed a syntax error and [ is correct in reporting a missing ']'. If you
do add the trailing ], as in "[ ] --help ]", you will then get a different
syntax error, since ] is not a valid first token in a 2-token expression.
- --
Life is short - so eat dessert first!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDmP1184KuGfSFAYARAtqRAJ97b3y4DomhjZvkWxwAuvfgg55towCgzr8Z
9UMDixS4Y0ANatEy9gk/9B0=
=H1r/
-----END PGP SIGNATURE-----
- bug with 'test', Adam Chou, 2005/12/08
- Re: bug with 'test', The Wanderer, 2005/12/08
- Re: bug with 'test',
Eric Blake <=
- Message not available
- Re: bug with 'test', Eric Blake, 2005/12/09
- Re: bug with 'test', Jim Meyering, 2005/12/09
- Re: bug with 'test', The Wanderer, 2005/12/09
- Re: bug with 'test', Paul Eggert, 2005/12/09
- Re: bug with 'test', The Wanderer, 2005/12/09
- Re: bug with 'test', Paul Eggert, 2005/12/10
- mailing list headers (Re: bug with 'test'), Bob Proulx, 2005/12/09
- Re: bug with 'test', Eric Blake, 2005/12/10