bug-bash
[Top][All Lists]
Advanced

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

Re: When double quote is considered when not?


From: Davide Brini
Subject: Re: When double quote is considered when not?
Date: Wed, 30 Mar 2011 11:47:20 +0100
User-agent: KMail/1.13.5 (Linux/2.6.36-gentoo-r5; KDE/4.4.5; x86_64; ; )

On Wednesday 30 Mar 2011 11:13:58 ali hagigat wrote:

> The following scripts were run for /bin/bash, version 4.0.33, and then
> comes their outputs. In the second example seems to have a warning:
> "binary operator expected". Why the error is generated? and why there
> is no error for the first example?
> ----------------------------------
> var1="word1     word2"
> echo $var1
> if (test -z "\"$var1\"")   then
> echo "first"
> else
> echo second
> fi
> 
> word1 word2
> second
> ----------------------------------
> var1="word1     word2"
> echo $var1
> if (test -z ""$var1"")   then
> echo "first"
> else
> echo second
> fi
> 
> word1 word2
> ./ss1: line 3: test: word1: binary operator expected
> second
> ----------------------------------

Use "set -x" at the beginning of the script and rerun it, and you'll 
immediately see why.

-- 
D.



reply via email to

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