diff options
author | 2005-09-11 18:02:27 +0000 | |
---|---|---|
committer | 2005-09-11 18:02:27 +0000 | |
commit | 57f623febe9a222b374289c4870fbe2e9eee764d (patch) | |
tree | 7e79f076c7797001ca2dd65d7122c4f18dad78bf | |
parent | Simplify code by changing struct scsi_mode_sense_buf{ union {} (diff) | |
download | wireguard-openbsd-57f623febe9a222b374289c4870fbe2e9eee764d.tar.xz wireguard-openbsd-57f623febe9a222b374289c4870fbe2e9eee764d.zip |
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 millert@
-rw-r--r-- | bin/ksh/exec.c | 4 | ||||
-rw-r--r-- | bin/ksh/lex.c | 10 | ||||
-rw-r--r-- | bin/ksh/lex.h | 3 |
3 files changed, 12 insertions, 5 deletions
diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c index 400f7357f80..20f0223504e 100644 --- a/bin/ksh/exec.c +++ b/bin/ksh/exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.c,v 1.41 2005/03/30 17:16:37 deraadt Exp $ */ +/* $OpenBSD: exec.c,v 1.42 2005/09/11 18:02:27 otto Exp $ */ /* * execute command tree @@ -1187,7 +1187,7 @@ herein(const char *content, int sub) 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); diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c index b06c590dd1f..5a5345a1903 100644 --- a/bin/ksh/lex.c +++ b/bin/ksh/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.36 2005/03/30 17:16:37 deraadt Exp $ */ +/* $OpenBSD: lex.c,v 1.37 2005/09/11 18:02:27 otto Exp $ */ /* * lexical analysis and source input @@ -289,10 +289,16 @@ yylex(int cf) 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 */ diff --git a/bin/ksh/lex.h b/bin/ksh/lex.h index ce66470b2c2..82cadf151f0 100644 --- a/bin/ksh/lex.h +++ b/bin/ksh/lex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.h,v 1.9 2004/12/18 21:04:52 millert Exp $ */ +/* $OpenBSD: lex.h,v 1.10 2005/09/11 18:02:27 otto Exp $ */ /* * Source input, lexer and parser @@ -111,6 +111,7 @@ typedef union { #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 */ |