diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2004-09-03 09:47:44 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2004-09-03 09:47:44 +0000 |
commit | 97fd0d9b8907827d786b92f6cc66618d57ac7518 (patch) | |
tree | 84e4930f9db51eb8f5bb82006fd752cf8900fdc3 /Src/builtin.c | |
parent | fb7907257503b2c8915d3623c694bfb21122b7df (diff) | |
download | zsh-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.c | 21 |
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; } |