Hi Chet,
It seems like the variable name validation for the mapfile builtin is a bit
wrong. I hope the patch below fixes it.
Demonstration:
| dualbus@hp ...local/src/bash % : before patch
| dualbus@hp ...local/src/bash % /bin/bash -c 'mapfile -t "a[\$(ls)]" <<< "";
declare -p'|grep -F '[$('
| declare -a a[$(ls)]='([0]="")'
|
| dualbus@hp ...local/src/bash % : after patch
| dualbus@hp ...local/src/bash % ./bash -c 'mapfile -t "a[\$(ls)]" <<< "";
declare -p'|grep -F '[$('
| ./bash: line 0: mapfile: `a[$(ls)]': not a valid identifier
Patch:
diff --git a/builtins/mapfile.def b/builtins/mapfile.def
index 5e258bb..51e37c6 100644
--- a/builtins/mapfile.def
+++ b/builtins/mapfile.def
@@ -349,7 +349,7 @@ mapfile_builtin (list)
else
array_name = list->word->word;
- if (legal_identifier (array_name) == 0 && valid_array_reference (array_name)
== 0)
+ if (legal_identifier (array_name) == 0)
{
sh_invalidid (array_name);
return (EXECUTION_FAILURE);