changes for backslashes in glob patterns and single-quoted strings; brace expansion knows '${...}' expansions; read returns status 2 if trying to assign to a readonly variable

This commit is contained in:
Chet Ramey
2023-10-17 11:09:23 -04:00
parent 7a698806d1
commit 1e1a0342a4
8 changed files with 73 additions and 37 deletions
+4 -2
View File
@@ -45,7 +45,7 @@
that we're translating a string for `echo -e', and therefore should not
treat a single quote as a character that may be escaped with a backslash.
If (FLAGS&2) is non-zero, we're expanding for the parser and want to
quote CTLESC and CTLNUL with CTLESC. If (flags&4) is non-zero, we want
quote CTLESC and CTLNUL with CTLESC. If (FLAGS&4) is non-zero, we want
to remove the backslash before any unrecognized escape sequence. */
char *
ansicstr (const char *string, size_t len, int flags, int *sawc, size_t *rlen)
@@ -198,7 +198,9 @@ ansicstr (const char *string, size_t len, int flags, int *sawc, size_t *rlen)
s++;
if ((flags & 2) && c == '\\' && c == *s)
s++; /* Posix requires $'\c\\' do backslash escaping */
c = TOCTRL(c);
else if ((flags & 2) && c == CTLESC && (*s == CTLESC || *s == CTLNUL))
c = *s++;
c = TOCTRL(c);
break;
}
/*FALLTHROUGH*/