Bug 77995 - bash test -l is broken
bash test -l is broken
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Ben Levenson
Depends On:
  Show dependency treegraph
Reported: 2002-11-16 21:37 EST by Robert K. Moniot
Modified: 2007-04-18 12:48 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-11-22 08:06:16 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Robert K. Moniot 2002-11-16 21:37:35 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020823

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:

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:

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).
Comment 1 Tim Waugh 2002-11-22 08:06:09 EST
Reported upstream.
Comment 2 Tim Waugh 2002-11-25 10:12:28 EST
Use ${#var} to compute string length.  It is intentional that -l was taken out.

Note You need to log in before you can comment on or make changes to this bug.