From e991806f2b8a1092ccc1f3441302aa08b712c4a5 Mon Sep 17 00:00:00 2001 From: tg Date: Wed, 22 Mar 2017 00:20:43 +0000 Subject: [PATCH] fixup LINENO in eval and alias; patch and initial testcase From: Martijn Dekker --- check.t | 24 +++++++++++++++++++++--- funcs.c | 3 ++- lex.c | 3 ++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/check.t b/check.t index d9fe080..ad17dff 100644 --- a/check.t +++ b/check.t @@ -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 diff --git a/funcs.c b/funcs.c index 3a49572..8471c4f 100644 --- a/funcs.c +++ b/funcs.c @@ -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 diff --git a/lex.c b/lex.c index 662c480..357a320 100644 --- a/lex.c +++ b/lex.c @@ -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 */