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?