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

Summary: bash test -l is broken
Product: [Retired] Red Hat Linux Reporter: Robert K. Moniot <moniot>
Component: bashAssignee: Tim Waugh <twaugh>
Status: CLOSED NOTABUG QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: kisch, mitr
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-11-22 13:06:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

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
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).

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.