fixup LINENO in eval and alias; patch and initial testcase

From: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
tg 2017-03-22 00:20:43 +00:00
parent 9466b49fe8
commit e991806f2b
3 changed files with 25 additions and 5 deletions

24
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.764 2017/03/19 22:31:24 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.765 2017/03/22 00:20:39 tg Exp $
# -*- mode: sh -*-
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -30,7 +30,7 @@
# (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout:
@(#)MIRBSD KSH R54 2017/03/19
@(#)MIRBSD KSH R54 2017/03/21
description:
Check version of shell.
stdin:
@ -39,7 +39,7 @@ name: KSH_VERSION
category: shell:legacy-no
---
expected-stdout:
@(#)LEGACY KSH R54 2017/03/19
@(#)LEGACY KSH R54 2017/03/21
description:
Check version of legacy shell.
stdin:
@ -5232,6 +5232,24 @@ expected-stdout:
line <6>
expected-exit: 1
---
name: lineno-eval-alias
description:
Check if LINENO is trapped in eval and aliases
stdin:
${ZSH_VERSION+false} || emulate sh; echo $LINENO
echo $LINENO
eval ' echo $LINENO
echo $LINENO
echo $LINENO'
echo $LINENO
expected-stdout:
1
2
3
3
3
6
---
name: unknown-trap
description:
Ensure unknown traps are not a syntax error

View File

@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.330 2017/03/19 20:59:25 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.331 2017/03/22 00:20:41 tg Exp $");
#if HAVE_KILLPG
/*
@ -2373,6 +2373,7 @@ c_eval(const char **wp)
return (1);
s = pushs(SWORDS, ATEMP);
s->u.strv = wp + builtin_opt.optind;
s->line = current_lineno;
/*-
* The following code handles the case where the command is

3
lex.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.230 2017/03/12 02:04:14 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.231 2017/03/22 00:20:43 tg Exp $");
/*
* states while lexing word
@ -1063,6 +1063,7 @@ yylex(int cf)
s->start = s->str = p->val.s;
s->u.tblp = p;
s->flags |= SF_HASALIAS;
s->line = source->line;
s->next = source;
if (source->type == SEOF) {
/* prevent infinite recursion at EOS */