From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 Description of problem: GNU bash, version 2.05b.0(1)-release (i686-pc-linux-gnu) The -l option to built-in test command does not work. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1.Run bash. Then try the following sequence of commands: $ n=11 $ if test -l $n -eq 2; then echo works ; fi Actual Results: -bash: test: -l: unary operator expected Expected Results: works Additional info: Behavior is the same using [ instead of test. The standalone test program works properly. Using $ if /usr/bin/test -l $n -eq 2; then echo works ; fi yields the expected result: works From man page for test (which is supposed to act the same as built-in) INTEGER may also be -l STRING, which evaluates to the length of STRING. Admittedly, the bash man page section on test does not mention the -l option. But bash used to support it, since I discovered this bug due a script ceasing to work right. Last time this particular script was used was probably in mid-2001, at which time I was probably running RedHat 6.2 or 7.1. Bug is also present in RedHat 7.2, bash 2.05a.0(1).
Reported upstream.
Use ${#var} to compute string length. It is intentional that -l was taken out.