On 6/11/17 5:57 PM, L A Walsh wrote:
> 
> 
> Chris F.A. Johnson wrote:
>> On Fri, 9 Jun 2017, L A Walsh wrote:
>>> ----
>>>   First problem: If you are assigning a string to a variable,
>>> you need to put quotes around the string.
>>
>>    You don't need to quote it unless it contains literal whitespace.
> ---
>    Not true if you want to reproduce the string as output by
> "declare".  Since declare doesn't output the literal value in a
> variable, but an expanded one, you need to put quotes around any
> var that you intend to expand with 'declare'.
> 
> Greg's example:
> 
>   imadev:~$ x=$'foo\nbar'
>   imadev:~$ declare -p x
>   declare -- x="foo
>   bar"
> 
> Shows that "declare" isn't quoting its output such that it can be used for
> assignment to a var, or as 'read' input.

You are misunderstanding what that is supposed to do, or ignoring it.
`declare -p' quotes its output in a way that allows it to be reused as
shell input. Executing the output of `declare -p' will recreate the
variable with an identical value.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to