Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Feb 2010 08:55:08 +0200
From:      Eray Aslan <eray.aslan@caf.com.tr>
To:        freebsd-questions@freebsd.org
Subject:   Re: simple (and stupid) shell scripting question
Message-ID:  <4B78EFCC.2010102@caf.com.tr>
In-Reply-To: <560f92641002142207w7eade79fr6a4f40ae5b92f4b9@mail.gmail.com>
References:  <560f92641002142207w7eade79fr6a4f40ae5b92f4b9@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 15.02.2010 08:07, Nerius Landys wrote:
> DIRNAME="`dirname \"$0\"`"
> cd "$DIRNAME"
> SCRIPTDIR="`pwd`"
> 
> What if I got rid of extra double quotes?  Like this:
> 
> DIRNAME=`dirname \"$0\"`
> cd "$DIRNAME"
> SCRIPTDIR=`pwd`
> 
> Does this behave any differently in any kind of case?  Are thes double
> quotes just superfluous?

>From the man page:

Command Substitution
[...]
 If  the  substitution  appears within double quotes, word splitting and
       pathname expansion are not performed on the results.

In other words:

sh-4.0$ touch "x y"
sh-4.0$ for i in `ls`; do echo "$i"; done
x
y
sh-4.0$ for i in "`ls`"; do echo "$i"; done
x y
sh-4.0$

-- 
Eray



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4B78EFCC.2010102>