diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 2000-03-11 00:02:48 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 2000-03-11 00:02:48 +0000 |
commit | 0cbd57cbe92e946da0501948291de5206650af67 (patch) | |
tree | 289a33f9519f52e657f368037ec6f4039016c2f6 /Src/init.c | |
parent | 388e580449468b7b111594e3e206ac42beafc82c (diff) | |
download | zsh-0cbd57cbe92e946da0501948291de5206650af67.tar.gz zsh-0cbd57cbe92e946da0501948291de5206650af67.tar.xz zsh-0cbd57cbe92e946da0501948291de5206650af67.zip |
zsh-workers/10041
Diffstat (limited to 'Src/init.c')
-rw-r--r-- | Src/init.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/Src/init.c b/Src/init.c index f35336fbf..fa3102a9b 100644 --- a/Src/init.c +++ b/Src/init.c @@ -890,12 +890,15 @@ init_misc(void) int source(char *s) { + Eprog prog; int tempfd, fd, cj, oldlineno; int oldshst, osubsh, oloops; FILE *obshin; - char *old_scriptname = scriptname; + char *old_scriptname = scriptname, *us; - if (!s || (tempfd = movefd(open(unmeta(s), O_RDONLY | O_NOCTTY))) == -1) { + if (!s || + (!(prog = try_source_file((us = unmeta(s)))) && + (tempfd = movefd(open(us, O_RDONLY | O_NOCTTY))) == -1)) { return 1; } @@ -908,8 +911,10 @@ source(char *s) oloops = loops; /* stored the # of nested loops we are in */ oldshst = opts[SHINSTDIN]; /* store current value of this option */ - SHIN = tempfd; - bshin = fdopen(SHIN, "r"); + if (!prog) { + SHIN = tempfd; + bshin = fdopen(SHIN, "r"); + } subsh = 0; lineno = 1; loops = 0; @@ -917,14 +922,24 @@ source(char *s) scriptname = s; sourcelevel++; - loop(0, 0); /* loop through the file to be sourced */ + if (prog) { + pushheap(); + errflag = 0; + execode(prog, 1, 0); + popheap(); + } else + loop(0, 0); /* loop through the file to be sourced */ sourcelevel--; - fclose(bshin); - fdtable[SHIN] = 0; /* restore the current shell state */ - SHIN = fd; /* the shell input fd */ - bshin = obshin; /* file handle for buffered shell input */ + if (prog) + freeeprog(prog); + else { + fclose(bshin); + fdtable[SHIN] = 0; + SHIN = fd; /* the shell input fd */ + bshin = obshin; /* file handle for buffered shell input */ + } subsh = osubsh; /* whether we are in a subshell */ thisjob = cj; /* current job number */ lineno = oldlineno; /* our current lineno */ |