mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-04 09:12:27 +02:00
more minor changes for builtins and array subscript expansion; fix to `wait -n'
This commit is contained in:
+11
-2
@@ -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 */
|
||||
|
||||
@@ -404,7 +404,7 @@ declare_internal (list, local_var)
|
||||
name = savestring (list->word->word);
|
||||
wflags = list->word->flags;
|
||||
#if defined (ARRAY_VARS)
|
||||
assoc_noexpand = assoc_expand_once && (wflags & W_ASSIGNMENT);
|
||||
assoc_noexpand = (assoc_expand_once || expand_once_flag) && (wflags & W_ASSIGNMENT);
|
||||
#else
|
||||
assoc_noexpand = 0;
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -269,7 +269,7 @@ printf_builtin (list)
|
||||
#if defined (ARRAY_VARS)
|
||||
arrayflags = assoc_expand_once ? VA_NOEXPAND : 0;
|
||||
if (assoc_expand_once && (list_optflags & W_ARRAYREF))
|
||||
arrayflags |= VA_ONEWORD; /* XXX - VA_NOEXPAND? */
|
||||
arrayflags |= VA_ONEWORD|VA_NOEXPAND;
|
||||
retval = legal_identifier (vname) || valid_array_reference (vname, arrayflags);
|
||||
#else
|
||||
retval = legal_identifier (vname);
|
||||
|
||||
+29
-9
@@ -128,7 +128,7 @@ static void set_eol_delim PARAMS((int));
|
||||
static void reset_eol_delim PARAMS((char *));
|
||||
static void set_readline_timeout PARAMS((sh_timer *t, time_t, long));
|
||||
#endif
|
||||
static SHELL_VAR *bind_read_variable PARAMS((char *, char *));
|
||||
static SHELL_VAR *bind_read_variable PARAMS((char *, char *, int));
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static int read_mbchar PARAMS((int, char *, int, int, int));
|
||||
#endif
|
||||
@@ -190,6 +190,20 @@ read_builtin_timeout (fd)
|
||||
: shtimer_select (read_timeout));
|
||||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
#define SET_VFLAGS(wordflags) \
|
||||
do { \
|
||||
vflags = assoc_expand_once ? VA_NOEXPAND : 0; \
|
||||
bindflags = assoc_expand_once ? ASS_NOEXPAND : 0; \
|
||||
if (assoc_expand_once && (wordflags & W_ARRAYREF)) \
|
||||
vflags |= VA_ONEWORD|VA_NOEXPAND; \
|
||||
if (vflags & VA_NOEXPAND) \
|
||||
bindflags |= ASS_NOEXPAND; \
|
||||
if (vflags & VA_ONEWORD) \
|
||||
bindflags |= ASS_ONEWORD; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/* Read the value of the shell variables whose names follow.
|
||||
The reading is done from the current input stream, whatever
|
||||
that may be. Successive words of the input line are assigned
|
||||
@@ -221,6 +235,7 @@ read_builtin (list)
|
||||
WORD_LIST *alist;
|
||||
int vflags;
|
||||
#endif
|
||||
int bindflags;
|
||||
#if defined (READLINE)
|
||||
char *rlbuf, *itext;
|
||||
int rlind;
|
||||
@@ -362,9 +377,11 @@ read_builtin (list)
|
||||
/* Convenience: check early whether or not the first of possibly several
|
||||
variable names is a valid identifier, and bail early if so. */
|
||||
#if defined (ARRAY_VARS)
|
||||
vflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
|
||||
if (list)
|
||||
SET_VFLAGS (list->word->flags);
|
||||
if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0)
|
||||
#else
|
||||
bindflags = 0;
|
||||
if (list && legal_identifier (list->word->word) == 0)
|
||||
#endif
|
||||
{
|
||||
@@ -952,6 +969,7 @@ assign_vars:
|
||||
{
|
||||
varname = list->word->word;
|
||||
#if defined (ARRAY_VARS)
|
||||
SET_VFLAGS (list->word->flags);
|
||||
if (legal_identifier (varname) == 0 && valid_array_reference (varname, vflags) == 0)
|
||||
#else
|
||||
if (legal_identifier (varname) == 0)
|
||||
@@ -975,16 +993,16 @@ assign_vars:
|
||||
if (t && saw_escape)
|
||||
{
|
||||
t1 = dequote_string (t);
|
||||
var = bind_read_variable (varname, t1);
|
||||
var = bind_read_variable (varname, t1, bindflags);
|
||||
free (t1);
|
||||
}
|
||||
else
|
||||
var = bind_read_variable (varname, t ? t : "");
|
||||
var = bind_read_variable (varname, t ? t : "", bindflags);
|
||||
}
|
||||
else
|
||||
{
|
||||
t = (char *)0;
|
||||
var = bind_read_variable (varname, "");
|
||||
var = bind_read_variable (varname, "", bindflags);
|
||||
}
|
||||
|
||||
FREE (t);
|
||||
@@ -1000,6 +1018,7 @@ assign_vars:
|
||||
|
||||
/* Now assign the rest of the line to the last variable argument. */
|
||||
#if defined (ARRAY_VARS)
|
||||
SET_VFLAGS (list->word->flags);
|
||||
if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0)
|
||||
#else
|
||||
if (legal_identifier (list->word->word) == 0)
|
||||
@@ -1036,11 +1055,11 @@ assign_vars:
|
||||
if (saw_escape && input_string && *input_string)
|
||||
{
|
||||
t = dequote_string (input_string);
|
||||
var = bind_read_variable (list->word->word, t);
|
||||
var = bind_read_variable (list->word->word, t, bindflags);
|
||||
free (t);
|
||||
}
|
||||
else
|
||||
var = bind_read_variable (list->word->word, input_string ? input_string : "");
|
||||
var = bind_read_variable (list->word->word, input_string ? input_string : "", bindflags);
|
||||
|
||||
if (var)
|
||||
{
|
||||
@@ -1057,12 +1076,13 @@ assign_vars:
|
||||
}
|
||||
|
||||
static SHELL_VAR *
|
||||
bind_read_variable (name, value)
|
||||
bind_read_variable (name, value, flags)
|
||||
char *name, *value;
|
||||
int flags;
|
||||
{
|
||||
SHELL_VAR *v;
|
||||
|
||||
v = builtin_bind_variable (name, value, 0);
|
||||
v = builtin_bind_variable (name, value, flags);
|
||||
return (v == 0 ? v
|
||||
: ((readonly_p (v) || noassign_p (v)) ? (SHELL_VAR *)NULL : v));
|
||||
}
|
||||
|
||||
@@ -151,7 +151,13 @@ wait_builtin (list)
|
||||
#if defined (ARRAY_VARS)
|
||||
int arrayflags;
|
||||
|
||||
#if 0
|
||||
arrayflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
|
||||
if (assoc_expand_once && (list_optflags & W_ARRAYREF))
|
||||
arrayflags |= VA_ONEWORD|VA_NOEXPAND;
|
||||
#else
|
||||
arrayflags = 0; /* not yet without builtin_bind_var_to_int support */
|
||||
#endif
|
||||
if (legal_identifier (vname) == 0 && valid_array_reference (vname, arrayflags) == 0)
|
||||
#else
|
||||
if (legal_identifier (vname) == 0)
|
||||
@@ -180,6 +186,8 @@ wait_builtin (list)
|
||||
last_command_exit_signal = wait_signal_received;
|
||||
status = 128 + wait_signal_received;
|
||||
wait_sigint_cleanup ();
|
||||
if (wflags & JWAIT_WAITING)
|
||||
unset_waitlist ();
|
||||
WAIT_RETURN (status);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user