bug-bash
[Top][All Lists]
Advanced

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

Re: Can't test "-l"


From: Paul Jarc
Subject: Re: Can't test "-l"
Date: 20 Dec 2000 10:48:59 -0500
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7

address@hidden (Chet Ramey) writes:
> > $ if [ "-l" != "-a" ] ; then echo "ok" ; fi
> > [: -a: binary operator expected                <----- ?
> > 
> > $ aa='-l'
> > $ if [ $aa != "-k" ] ; then echo "ok" ; fi
> > [: -k: binary operator expected                <----- ?
> 
> Here's the relevant item from the bash-2.05 COMPAT file:
> 
> 15.  Bash versions up to 1.14.7 included an undocumented `-l' operator to
>      the `test/[' builtin.
...
>      This operator is not part of the POSIX standard, because one can (and
>      should) use ${#variable} to get the length of a variable's value.
>      Bash-2.x does not support it.

I think what he means is that generally, he wants to operate on
strings which could be interpreted as operators.  E.g., with 2.04:
$ [ "-z" != "-a" ]; echo $?
0
$ [ -z "!=" -a -z "!=" ]; echo $?
[: too many arguments
2

I don't think infix operators can solve this problem.  BTW, what's up
with this:

$ [ -z foo ]; echo $?
1
$ [ -z foo ]
$ echo $?
0
$ echo $PROMPT_COMMAND # just checking...
$ 


paul



reply via email to

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