On 10/10/10 8:46 PM, Devin Teske wrote:
On Oct 10, 2010, at 4:51 PM, Garance A Drosihn <dro...@rpi.edu
<mailto:dro...@rpi.edu>> wrote:

The latter does not cause an error. Try it:

# [ "-n" = x ] ; echo $?
1

# [ -e = "no" ] ; echo $?
1

# [ -e = -n ] ; echo $?
1

1 is error. 0 is success.
--


Um, yes, true.  I know that.  What I'm saying is that
the command works as you'd want it to work.  It does
not hit a parsing error.  The double-quotes did not
change how the command behaved.  You deleted the
context of what I was replying to when I said the
above. Looking at the examples I gave there, it probably
would have been clearer if I had typed the exact same
command with and without the double-quotes.  Eg:

On 10/10/10 7:09 PM, Devin Teske wrote:
>  However, enclosing the argument (as the 'x$foo'
>  portion is really just the first argument to the
> '[' built-in) in quotes:
>
> [ "$foo" = x ]
>
>  makes it so that the expansion is taken as:
>
> [ "-n" = x ]
>
>  rather than:
>
> [ -n = x ]
>
>  The former not causing an error, while the latter does.

Your second example does not cause an error. Try it:

# [ "-n" = "-n" ] ; echo $?
0
# [ "-n" = x ] ; echo $?
1

Compared to the double-quote-less:

# [ -n = "-n" ] ; echo $?
0
# [ -n = x ] ; echo $?
1

--
Garance
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to