bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ -n ] != [ -n "" ] in 2.05a


From: Chet Ramey
Subject: Re: [ -n ] != [ -n "" ] in 2.05a
Date: Thu, 13 Dec 2001 10:27:41 -0500

> [ -n ] && echo "bug"
> 
> will print "bug".

As it should.

> I'd have expected [ -n ] would be the same as [ -n "" ]...

Bad expectation.

> (Affects the variants thereof, as well, e.g.
> unset FOO
> [ -n $FOO ] && echo "bug")

Bad programming practice.

Look at question E1 in the Bash FAQ for an explanation.  Equivalent
text appears in the bash man page.


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]