about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-09-03 09:47:44 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-09-03 09:47:44 +0000
commit97fd0d9b8907827d786b92f6cc66618d57ac7518 (patch)
tree84e4930f9db51eb8f5bb82006fd752cf8900fdc3 /Src/builtin.c
parentfb7907257503b2c8915d3623c694bfb21122b7df (diff)
downloadzsh-97fd0d9b8907827d786b92f6cc66618d57ac7518.tar.gz
zsh-97fd0d9b8907827d786b92f6cc66618d57ac7518.tar.xz
zsh-97fd0d9b8907827d786b92f6cc66618d57ac7518.zip
20308: add EVAL_LINENO option
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c21
1 files changed, 18 insertions, 3 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;
 }