Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Feb 2010 14:10: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:  <4B7939A0.6020102@caf.com.tr>
In-Reply-To: <560f92641002142321s246f15fcg6f233b0c152e1d6a@mail.gmail.com>
References:  <560f92641002142207w7eade79fr6a4f40ae5b92f4b9@mail.gmail.com>	<4B78EFCC.2010102@caf.com.tr> <560f92641002142321s246f15fcg6f233b0c152e1d6a@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 15.02.2010 09:21, Nerius Landys wrote:
> But in the case where you're assigning the output of ls directly to a
> variable like this:
> 
> FOO=`ls`
> 
> vs
> 
> FOO="`ls`"
> 
> the text assigned to FOO is the same, right?

Apparently, it is:

sh-4.0$ touch "x *"
sh-4.0$ FOO=`ls`;echo "$FOO"|od
0000000 020170 005052
0000004
sh-4.0$ BAR="`ls`"; echo "$BAR"|od
0000000 020170 005052
0000004

There might be some corner cases tho.  Test before puting into
production (newlines/control chars in file names, different versions of
shell, different set/shopt options, changes in IFS etc).

-- 
Eray



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