Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 89178

Summary: test command doesn't know -l switch
Product: Gentoo Linux Reporter: Clock <clock>
Component: Current packagesAssignee: Aron Griffis (RETIRED) <agriffis>
Status: RESOLVED INVALID    
Severity: minor    
Priority: High    
Version: unspecified   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Clock 2005-04-15 06:58:39 UTC
man test:"INTEGER may also be -l STRING, which evaluates to the length of STRING."

bash-2.05b$ test [ -l "bla" -ge 4 ]
bash: test: too many arguments

also, info test doesn't list the "-l" switch.

Reproducible: Always
Steps to Reproduce:
1.test [ -l "bla" -ge 4 ]
2.
3.

Actual Results:  
test: too many arguments

Expected Results:  
$?=1

It looks like the manpage is outdated
Comment 1 Aron Griffis (RETIRED) gentoo-dev 2005-04-20 13:53:01 UTC
Actually, there are multiple levels of user error in play here.  First, by default when you call "test" at the command-line, you get the bash builtin version.  The bash builtin version is documented in the bash man-page and also via "help test"

To get the external version, i.e. the version that comes with coreutils and is documented in test(1), you need to call it explicitly:

  /usr/bin/test 3 -eq -l "abc"

Second, you're misusing the command.  /usr/bin/test and /usr/bin/[ are the same command.  Never should you be calling "test [ ... ]", rather you do either "test ..." or "[ ... ]"

Finally, all of these things are in fact documented in "info test"; I just checked.