diff options
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/expand.c | 5 | ||||
-rw-r--r-- | src/mksyntax.c | 5 | ||||
-rw-r--r-- | src/parser.c | 4 |
4 files changed, 12 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog index b22197f..dca08d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-09-24 Herbert Xu <herbert@gondor.apana.org.au> + + * Do not quote back slashes in parameter expansions outside quotes. + 2007-09-22 Oleg Verych <olecom@flower.upol.cz> * White space fixes for test(1). diff --git a/src/expand.c b/src/expand.c index db67c7c..3956112 100644 --- a/src/expand.c +++ b/src/expand.c @@ -895,7 +895,7 @@ memtodest(const char *p, size_t len, const char *syntax, int quotes) { int c = (signed char)*p++; if (c) { if ((quotes & QUOTES_ESC) && - (syntax[c] == CCTL || syntax[c] == CBACK)) + (syntax[c] == CCTL || syntax[c] == CDBACK)) USTPUTC(CTLESC, q); } else if (!(quotes & QUOTES_KEEPNUL)) continue; @@ -1671,9 +1671,8 @@ _rmescapes(char *str, int flag) } if (*p == (char)CTLESC) { p++; - if (notescaped && inquotes && *p != '/') { + if (notescaped && inquotes) *q++ = '\\'; - } } notescaped = globbing; copy: diff --git a/src/mksyntax.c b/src/mksyntax.c index 7a8a9ae..9ecbb45 100644 --- a/src/mksyntax.c +++ b/src/mksyntax.c @@ -53,6 +53,7 @@ struct synclass synclass[] = { { "CWORD", "character is nothing special" }, { "CNL", "newline character" }, { "CBACK", "a backslash character" }, + { "CDBACK", "a backslash character in double quotes" }, { "CSQUOTE", "single quote" }, { "CDQUOTE", "double quote" }, { "CENDQUOTE", "a terminating quote" }, @@ -175,7 +176,7 @@ main(int argc, char **argv) init(); fputs("\n/* syntax table used when in double quotes */\n", cfile); add("\n", "CNL"); - add("\\", "CBACK"); + add("\\", "CDBACK"); add("\"", "CENDQUOTE"); add("`", "CBQUOTE"); add("$", "CVAR"); @@ -193,7 +194,7 @@ main(int argc, char **argv) init(); fputs("\n/* syntax table used when in arithmetic */\n", cfile); add("\n", "CNL"); - add("\\", "CBACK"); + add("\\", "CDBACK"); add("`", "CBQUOTE"); add("$", "CVAR"); add("}", "CENDVAR"); diff --git a/src/parser.c b/src/parser.c index 6faff17..279d49e 100644 --- a/src/parser.c +++ b/src/parser.c @@ -891,7 +891,9 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs) USTPUTC(CTLESC, out); USTPUTC(c, out); break; - case CBACK: /* backslash */ + /* backslash */ + case CBACK: + case CDBACK: c = pgetc2(); if (c == PEOF) { USTPUTC(CTLESC, out); |