check not-begun heredocs at EOF earlier
izabera reported they were not caught with “set -n”
This commit is contained in:
parent
25a564460e
commit
c2bdb1b9dd
36
check.t
36
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.725 2016/02/26 22:03:10 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.726 2016/03/01 18:30:01 tg Exp $
|
||||||
# -*- mode: sh -*-
|
# -*- mode: sh -*-
|
||||||
#-
|
#-
|
||||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
@ -30,7 +30,7 @@
|
|||||||
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
|
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R52 2016/02/26
|
@(#)MIRBSD KSH R52 2016/03/01
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -39,7 +39,7 @@ name: KSH_VERSION
|
|||||||
category: shell:legacy-no
|
category: shell:legacy-no
|
||||||
---
|
---
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)LEGACY KSH R52 2016/02/26
|
@(#)LEGACY KSH R52 2016/03/01
|
||||||
description:
|
description:
|
||||||
Check version of legacy shell.
|
Check version of legacy shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -2249,7 +2249,7 @@ expected-stdout:
|
|||||||
hi
|
hi
|
||||||
there
|
there
|
||||||
---
|
---
|
||||||
name: heredoc-4
|
name: heredoc-4a
|
||||||
description:
|
description:
|
||||||
Check that an error occurs if the heredoc-delimiter is missing.
|
Check that an error occurs if the heredoc-delimiter is missing.
|
||||||
stdin: !
|
stdin: !
|
||||||
@ -2259,6 +2259,34 @@ stdin: !
|
|||||||
expected-exit: e > 0
|
expected-exit: e > 0
|
||||||
expected-stderr-pattern: /.*/
|
expected-stderr-pattern: /.*/
|
||||||
---
|
---
|
||||||
|
name: heredoc-4an
|
||||||
|
description:
|
||||||
|
Check that an error occurs if the heredoc-delimiter is missing.
|
||||||
|
arguments: !-n!
|
||||||
|
stdin: !
|
||||||
|
cat << EOF
|
||||||
|
hi
|
||||||
|
there
|
||||||
|
expected-exit: e > 0
|
||||||
|
expected-stderr-pattern: /.*/
|
||||||
|
---
|
||||||
|
name: heredoc-4b
|
||||||
|
description:
|
||||||
|
Check that an error occurs if the heredoc is missing.
|
||||||
|
stdin: !
|
||||||
|
cat << EOF
|
||||||
|
expected-exit: e > 0
|
||||||
|
expected-stderr-pattern: /.*/
|
||||||
|
---
|
||||||
|
name: heredoc-4bn
|
||||||
|
description:
|
||||||
|
Check that an error occurs if the heredoc is missing.
|
||||||
|
arguments: !-n!
|
||||||
|
stdin: !
|
||||||
|
cat << EOF
|
||||||
|
expected-exit: e > 0
|
||||||
|
expected-stderr-pattern: /.*/
|
||||||
|
---
|
||||||
name: heredoc-5
|
name: heredoc-5
|
||||||
description:
|
description:
|
||||||
Check that backslash quotes a $, ` and \ and kills a \newline
|
Check that backslash quotes a $, ` and \ and kills a \newline
|
||||||
|
9
exec.c
9
exec.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.171 2016/01/21 18:24:39 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.172 2016/03/01 18:30:04 tg Exp $");
|
||||||
|
|
||||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||||
#define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh"
|
#define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh"
|
||||||
@ -1581,13 +1581,6 @@ herein(struct ioword *iop, char **resbuf)
|
|||||||
struct temp *h;
|
struct temp *h;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* ksh -c 'cat <<EOF' can cause this... */
|
|
||||||
if (iop->heredoc == NULL && !(iop->ioflag & IOHERESTR)) {
|
|
||||||
warningf(true, Tmissinghere);
|
|
||||||
/* special to iosetup(): don't print error */
|
|
||||||
return (-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lexer substitution flags */
|
/* lexer substitution flags */
|
||||||
i = (iop->ioflag & IOEVAL) ? (ONEWORD | HEREDOC) : 0;
|
i = (iop->ioflag & IOEVAL) ? (ONEWORD | HEREDOC) : 0;
|
||||||
|
|
||||||
|
14
lex.c
14
lex.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.220 2016/03/01 18:00:08 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.221 2016/03/01 18:30:04 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* states while lexing word
|
* states while lexing word
|
||||||
@ -1000,6 +1000,16 @@ yylex(int cf)
|
|||||||
if (cf & CONTIN)
|
if (cf & CONTIN)
|
||||||
goto Again;
|
goto Again;
|
||||||
}
|
}
|
||||||
|
} else if (c == '\0' && !(cf & HEREDELIM)) {
|
||||||
|
struct ioword **p = heres;
|
||||||
|
|
||||||
|
while (p < herep)
|
||||||
|
if ((*p)->ioflag & IOHERESTR)
|
||||||
|
++p;
|
||||||
|
else
|
||||||
|
/* ksh -c 'cat <<EOF' can cause this */
|
||||||
|
yyerror("here document '%s' unclosed\n",
|
||||||
|
evalstr((*p)->delim, 0));
|
||||||
}
|
}
|
||||||
return (c);
|
return (c);
|
||||||
}
|
}
|
||||||
@ -1173,7 +1183,7 @@ readhere(struct ioword *iop)
|
|||||||
while (c != '\n') {
|
while (c != '\n') {
|
||||||
if (!c)
|
if (!c)
|
||||||
/* oops, reached EOF */
|
/* oops, reached EOF */
|
||||||
yyerror("%s '%s' unclosed\n", Theredoc, eof);
|
yyerror("here document '%s' unclosed\n", eof);
|
||||||
/* store character */
|
/* store character */
|
||||||
Xcheck(xs, xp);
|
Xcheck(xs, xp);
|
||||||
Xput(xs, xp, c);
|
Xput(xs, xp, c);
|
||||||
|
10
sh.h
10
sh.h
@ -175,9 +175,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.765 2016/02/26 21:53:37 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.766 2016/03/01 18:30:05 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R52 2016/02/26"
|
#define MKSH_VERSION "R52 2016/03/01"
|
||||||
|
|
||||||
/* arithmetic types: C implementation */
|
/* arithmetic types: C implementation */
|
||||||
#if !HAVE_CAN_INTTYPES
|
#if !HAVE_CAN_INTTYPES
|
||||||
@ -887,12 +887,6 @@ EXTERN const char T_funny_command[] E_INIT("funny $() command");
|
|||||||
EXTERN const char Tfg_badsubst[] E_INIT("fileglob: bad substitution");
|
EXTERN const char Tfg_badsubst[] E_INIT("fileglob: bad substitution");
|
||||||
#endif
|
#endif
|
||||||
#define Tbadsubst (Tfg_badsubst + 10) /* "bad substitution" */
|
#define Tbadsubst (Tfg_badsubst + 10) /* "bad substitution" */
|
||||||
#if defined(__GNUC__)
|
|
||||||
#define Tmissinghere "missing here document"
|
|
||||||
#else
|
|
||||||
EXTERN const char Tmissinghere[] E_INIT("missing here document");
|
|
||||||
#endif
|
|
||||||
#define Theredoc (Tmissinghere + 8) /* "here document" */
|
|
||||||
EXTERN const char TC_LEX1[] E_INIT("|&;<>() \t\n");
|
EXTERN const char TC_LEX1[] E_INIT("|&;<>() \t\n");
|
||||||
#define TC_IFSWS (TC_LEX1 + 7) /* space tab newline */
|
#define TC_IFSWS (TC_LEX1 + 7) /* space tab newline */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user