[Top][All Lists]

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

Re: declare a="$b" if $a previously set as array

From: Linda Walsh
Subject: Re: declare a="$b" if $a previously set as array
Date: Sun, 07 Dec 2014 19:34:53 -0800
User-agent: Thunderbird

Stephane Chazelas wrote:
   declare -l a="$external_input"

he's entitled to expect $a to contain the lower case version of
$external_input whatever $external_input contain.
Only if you properly quote "external input".

If you properly quote the external input I don't see the problem:

Does this example demonstrate your setup?

declare -a a=(1 2 3)
b='($(echo FOO))'
printf -v qb "%q" "$b"    # here must quote the raw 'external input' string
declare -l a=$qb          # redefining 'a' to be lower case
read c <<<$a # read the quoted value printf "%s\n" "$c"
($(echo foo))               # no execution -- just the case lowering you want

Am I missing something?

If $external_input happens to contain "($(echo FOO))", I'd
expect $a to contain "($(echo foo))", not "foo" just because
$external_input happens to follow a specific pattern.
Does the above work for you?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]