The following should print \"; from OpenBSD

$ cat << EOF
\"
EOF
This commit is contained in:
christos 2005-09-11 22:16:00 +00:00
parent cf017dd18f
commit 57c8db64ce
3 changed files with 15 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.c,v 1.11 2005/06/26 19:09:00 christos Exp $ */
/* $NetBSD: exec.c,v 1.12 2005/09/11 22:16:00 christos Exp $ */
/*
* execute command tree
@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: exec.c,v 1.11 2005/06/26 19:09:00 christos Exp $");
__RCSID("$NetBSD: exec.c,v 1.12 2005/09/11 22:16:00 christos Exp $");
#endif
@ -1484,7 +1484,7 @@ herein(content, 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);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lex.c,v 1.11 2005/04/19 20:14:29 rillig Exp $ */
/* $NetBSD: lex.c,v 1.12 2005/09/11 22:16:00 christos Exp $ */
/*
* lexical analysis and source input
@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: lex.c,v 1.11 2005/04/19 20:14:29 rillig Exp $");
__RCSID("$NetBSD: lex.c,v 1.12 2005/09/11 22:16:00 christos Exp $");
#endif
@ -248,10 +248,16 @@ yylex(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 */

View File

@ -1,10 +1,10 @@
/* $NetBSD: lex.h,v 1.6 2004/07/07 19:20:09 mycroft Exp $ */
/* $NetBSD: lex.h,v 1.7 2005/09/11 22:16:00 christos Exp $ */
/*
* Source input, lexer and parser
*/
/* $Id: lex.h,v 1.6 2004/07/07 19:20:09 mycroft Exp $ */
/* $Id: lex.h,v 1.7 2005/09/11 22:16:00 christos Exp $ */
#define IDENT 64
@ -115,6 +115,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 */