summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c21
-rw-r--r--Src/exec.c4
-rw-r--r--Src/options.c1
-rw-r--r--Src/zsh.h1
4 files changed, 22 insertions, 5 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 294b405b3..44d85b80a 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -4220,27 +4220,42 @@ bin_emulate(UNUSED(char *nam), char **argv, Options ops, UNUSED(int func))
/* eval: simple evaluation */
/**/
+int ineval;
+
+/**/
int
bin_eval(UNUSED(char *nam), char **argv, UNUSED(Options ops), UNUSED(int func))
{
Eprog prog;
char *oscriptname = scriptname;
-
- scriptname = "(eval)";
+ int oineval = ineval;
+ /*
+ * If EVALLINENO is not set, we use the line number of the
+ * environment and must flag this up to exec.c. Otherwise,
+ * we use a special script name to indicate the special line number.
+ */
+ ineval = !isset(EVALLINENO);
prog = parse_string(zjoin(argv, ' ', 1));
if (!prog) {
errflag = 0;
return 1;
}
+
lastval = 0;
+ if (!ineval)
+ scriptname = "(eval)";
+
execode(prog, 1, 0);
+
if (errflag) {
lastval = errflag;
errflag = 0;
}
- scriptname = oscriptname;
+ if (!ineval)
+ scriptname = oscriptname;
+ ineval = oineval;
return lastval;
}
diff --git a/Src/exec.c b/Src/exec.c
index d1c3bb98e..5fd2a2e30 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -788,7 +788,7 @@ execsimple(Estate state)
return (lastval = 1);
/* In evaluated traps, don't modify the line number. */
- if ((!intrap || trapisfunc) && code)
+ if ((!intrap || trapisfunc) && !ineval && code)
lineno = code - 1;
code = wc_code(*state->pc++);
@@ -1260,7 +1260,7 @@ execpline2(Estate state, wordcode pcode,
return;
/* In evaluated traps, don't modify the line number. */
- if ((!intrap || trapisfunc) && WC_PIPE_LINENO(pcode))
+ if ((!intrap || trapisfunc) && !ineval && WC_PIPE_LINENO(pcode))
lineno = WC_PIPE_LINENO(pcode) - 1;
if (pline_level == 1) {
diff --git a/Src/options.c b/Src/options.c
index 21d9d00ed..70a7364fc 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -115,6 +115,7 @@ static struct optname optns[] = {
{NULL, "exec", OPT_ALL, EXECOPT},
{NULL, "extendedglob", OPT_EMULATE, EXTENDEDGLOB},
{NULL, "extendedhistory", OPT_CSH, EXTENDEDHISTORY},
+{NULL, "evallineno", OPT_EMULATE|OPT_ZSH, EVALLINENO},
{NULL, "flowcontrol", OPT_ALL, FLOWCONTROL},
{NULL, "functionargzero", OPT_EMULATE|OPT_NONBOURNE, FUNCTIONARGZERO},
{NULL, "glob", OPT_EMULATE|OPT_ALL, GLOBOPT},
diff --git a/Src/zsh.h b/Src/zsh.h
index 1501fdf8e..40d506044 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1445,6 +1445,7 @@ enum {
EXECOPT,
EXTENDEDGLOB,
EXTENDEDHISTORY,
+ EVALLINENO,
FLOWCONTROL,
FUNCTIONARGZERO,
GLOBOPT,