Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 77995 - bash test -l is broken
Summary: bash test -l is broken
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: bash
Version: 8.0
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Ben Levenson
Depends On:
TreeView+ depends on / blocked
Reported: 2002-11-17 02:37 UTC by Robert K. Moniot
Modified: 2007-04-18 16:48 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2002-11-22 13:06:16 UTC

Attachments (Terms of Use)

Description Robert K. Moniot 2002-11-17 02:37:35 UTC
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 13:06:09 UTC
Reported upstream.

Comment 2 Tim Waugh 2002-11-25 15:12:28 UTC
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.