summaryrefslogtreecommitdiff
path: root/general.c
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2020-09-09 15:25:32 -0400
committerChet Ramey <chet.ramey@case.edu>2020-09-09 15:25:32 -0400
commit3eb0018e75b74bb886df7fba4b1712529ce7258f (patch)
tree13b53713ef8f483a82295324e314da48b59c9346 /general.c
parent712f80b0a49c3a0227d0b52bff5e0b763747697e (diff)
downloadbash-5.1-beta.tar.gz
bash-5.1 beta releasebash-5.1-beta
Diffstat (limited to 'general.c')
-rw-r--r--general.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/general.c b/general.c
index 9be3c440..50d52167 100644
--- a/general.c
+++ b/general.c
@@ -425,7 +425,8 @@ legal_alias_name (string, flags)
/* Returns non-zero if STRING is an assignment statement. The returned value
is the index of the `=' sign. If FLAGS&1 we are expecting a compound assignment
- and don't want an array subscript before the `='. */
+ and require an array subscript before the `=' to denote an assignment
+ statement. */
int
assignment (string, flags)
const char *string;
@@ -437,7 +438,17 @@ assignment (string, flags)
c = string[indx = 0];
#if defined (ARRAY_VARS)
- if ((legal_variable_starter (c) == 0) && ((flags&1) == 0 || c != '[')) /* ] */
+ /* If parser_state includes PST_COMPASSIGN, FLAGS will include 1, so we are
+ parsing the contents of a compound assignment. If parser_state includes
+ PST_REPARSE, we are in the middle of an assignment statement and breaking
+ the words between the parens into words and assignment statements, but
+ we don't need to check for that right now. Within a compound assignment,
+ the subscript is required to make the word an assignment statement. If
+ we don't have a subscript, even if the word is a valid assignment
+ statement otherwise, we don't want to treat it as one. */
+ if ((flags & 1) && c != '[') /* ] */
+ return (0);
+ else if ((flags & 1) == 0 && legal_variable_starter (c) == 0)
#else
if (legal_variable_starter (c) == 0)
#endif