[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How to understand "set --"?
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] How to understand "set --"? |
Date: |
Wed, 19 Feb 2014 08:40:41 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Tue, Feb 18, 2014 at 10:12:26PM -0600, Peng Yu wrote:
> ~/linux/test/bash/man/builtin/set/--$ x="'abc def'"
> ~/linux/test/bash/man/builtin/set/--$ set -- $x
If you want to store a list of strings, you CANNOT do so in a scalar
variable (like your x="..." above). You must use an array.
If on the other hand you wanted the single quotes to be part of the
literal data, so that x contains just a single string which includes
that punctuation, then you need to quote "$x" on the second line to
avoid word splitting and globbing of the result.
These two goals are completely exclusive. You either want a list of
strings, OR you want a single string with weird crap in it. We would
need to know which one you wanted in order to advise you on the
proper syntax.
x=(this 'is an' "array of $foo" "$bar")
set -- "address@hidden"
x=$'This is a \'single string\' with literal "single-quotes" inside it'
set -- "$x"