diff options
Diffstat (limited to 'system/pdksh/patches/105_OpenBSD-heredoc-quote.patch')
-rw-r--r-- | system/pdksh/patches/105_OpenBSD-heredoc-quote.patch | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/system/pdksh/patches/105_OpenBSD-heredoc-quote.patch b/system/pdksh/patches/105_OpenBSD-heredoc-quote.patch new file mode 100644 index 0000000000..1cb8577437 --- /dev/null +++ b/system/pdksh/patches/105_OpenBSD-heredoc-quote.patch @@ -0,0 +1,53 @@ +Fix for `Bug#219343 backslash is swallowed in HERE document' from OpenBSD: + * exec.c (1.42), lex.c (1.37), lex.h (1.10): Fix " handling in here + documents. POSIX says they are not special, so cat << EOF \" EOF + should print \" Fixes PR 4472; testing jmc@ and Adam Montague. ok +(from OpenBSD) + +Index: pdksh-5.2.14/exec.c +=================================================================== +--- pdksh-5.2.14.orig/exec.c 2009-09-17 00:32:31.000000000 +0200 ++++ pdksh-5.2.14/exec.c 2009-09-17 00:32:59.000000000 +0200 +@@ -1480,7 +1480,7 @@ + s = pushs(SSTRING, ATEMP); + s->start = s->str = content; + source = s; +- if (yylex(ONEWORD) != LWORD) ++ if (yylex(ONEWORD|HEREDOC) != LWORD) + internal_errorf(1, "herein: yylex"); + source = osource; + shf_puts(evalstr(yylval.cp, 0), shf); +Index: pdksh-5.2.14/lex.c +=================================================================== +--- pdksh-5.2.14.orig/lex.c 2009-09-17 00:32:52.000000000 +0200 ++++ pdksh-5.2.14/lex.c 2009-09-17 00:32:59.000000000 +0200 +@@ -240,10 +240,16 @@ + case '\\': + c = getsc(); + switch (c) { +- case '"': case '\\': ++ case '\\': + case '$': case '`': + *wp++ = QCHAR, *wp++ = c; + break; ++ case '"': ++ if ((cf & HEREDOC) == 0) { ++ *wp++ = QCHAR, *wp++ = c; ++ break; ++ } ++ /* FALLTROUGH */ + default: + Xcheck(ws, wp); + if (c) { /* trailing \ is lost */ +Index: pdksh-5.2.14/lex.h +=================================================================== +--- pdksh-5.2.14.orig/lex.h 2009-09-17 00:31:55.000000000 +0200 ++++ pdksh-5.2.14/lex.h 2009-09-17 00:32:59.000000000 +0200 +@@ -113,6 +113,7 @@ + #define ESACONLY BIT(7) /* only accept esac keyword */ + #define CMDWORD BIT(8) /* parsing simple command (alias related) */ + #define HEREDELIM BIT(9) /* parsing <<,<<- delimiter */ ++#define HEREDOC BIT(10) /* parsing heredoc */ + + #define HERES 10 /* max << in line */ + |