more minor changes for builtins and array subscript expansion; fix to `wait -n'

This commit is contained in:
Chet Ramey
2021-05-17 12:03:03 -04:00
parent 88bdb448b4
commit 7b024db83e
14 changed files with 106 additions and 25 deletions
+11 -2
View File
@@ -971,6 +971,7 @@ builtin_help ()
/* */
/* **************************************************************** */
/* Assign NAME=VALUE, passing FLAGS to the assignment functions. */
SHELL_VAR *
builtin_bind_variable (name, value, flags)
char *name;
@@ -978,6 +979,7 @@ builtin_bind_variable (name, value, flags)
int flags;
{
SHELL_VAR *v;
int vflags, bindflags;
#if defined (ARRAY_VARS)
/* Callers are responsible for calling this with array references that have
@@ -985,10 +987,17 @@ builtin_bind_variable (name, value, flags)
Affected builtins: read, printf
To make this really work, needs additional downstream support, starting
with assign_array_element and array_variable_name. */
if (valid_array_reference (name, assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0) == 0)
vflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
bindflags = flags | (assoc_expand_once ? ASS_NOEXPAND : 0) | ASS_ALLOWALLSUB;
if (flags & ASS_NOEXPAND)
vflags |= VA_NOEXPAND;
if (flags & ASS_ONEWORD)
vflags |= VA_ONEWORD;
if (valid_array_reference (name, vflags) == 0)
v = bind_variable (name, value, flags);
else
v = assign_array_element (name, value, flags | (assoc_expand_once ? ASS_NOEXPAND : 0) | ASS_ALLOWALLSUB);
v = assign_array_element (name, value, bindflags);
#else /* !ARRAY_VARS */
v = bind_variable (name, value, flags);
#endif /* !ARRAY_VARS */