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

Re: bash shell variables with spaces



On Mon, Jul 19, 2004 at 10:33:02AM +1000, Zenaan Harkness wrote:
> Which raises the question - what if the expansion contains double quote
> chars? Perhaps using double-backslash (or quad??) would do the trick?

You mean like this?:

$ FOO='foo "more foo" bar'
$ echo "$FOO"
foo "more foo" bar

This works because the shell when parsing the echo line first expands
$FOO, which results in 'echo "foo "more foo" bar"' and then it performes
quote removal but only on those quotes that did not result from a
previous expansion. Since the quotes around "more foo" result from
expanding $FOO, they are not removed.

Regards
Matthias



Reply to: