diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2009-07-11 16:42:53 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2009-07-11 16:42:53 +0000 |
commit | bdfebe3e3262eaaf83e89c9356c7c46a21181a6a (patch) | |
tree | 87027d549b390d53ab682c872c83b93ce8f98250 /Src/init.c | |
parent | a8fb2bbc3d580ebff421a02b9499be6a8a20b055 (diff) | |
download | zsh-bdfebe3e3262eaaf83e89c9356c7c46a21181a6a.tar.gz zsh-bdfebe3e3262eaaf83e89c9356c7c46a21181a6a.tar.xz zsh-bdfebe3e3262eaaf83e89c9356c7c46a21181a6a.zip |
27129: fix status at start of function, command subst, etc.
Diffstat (limited to 'Src/init.c')
-rw-r--r-- | Src/init.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/Src/init.c b/Src/init.c index b3224f65a..b807f0659 100644 --- a/Src/init.c +++ b/Src/init.c @@ -99,11 +99,11 @@ mod_export struct hookdef zshhooks[] = { /* keep executing lists until EOF found */ /**/ -int +enum loop_return loop(int toplevel, int justonce) { Eprog prog; - int err; + int err, non_empty = 0; pushheap(); if (!toplevel) @@ -151,6 +151,7 @@ loop(int toplevel, int justonce) if (hend(prog)) { int toksav = tok; + non_empty = 1; if (toplevel && (getshfunc("preexec") || paramtab->getnode(paramtab, "preexec" HOOK_SUFFIX))) { @@ -207,7 +208,11 @@ loop(int toplevel, int justonce) lexrestore(); popheap(); - return err; + if (err) + return LOOP_ERROR; + if (!non_empty) + return LOOP_EMPTY; + return LOOP_OK; } static char *cmd; @@ -1131,7 +1136,6 @@ source(char *s) fstack.tp = FS_SOURCE; funcstack = &fstack; - lastval = 0; /* status of empty file is zero */ if (prog) { pushheap(); errflag = 0; @@ -1141,8 +1145,21 @@ source(char *s) ret = SOURCE_ERROR; } else { /* loop through the file to be sourced */ - if (loop(0, 0)) + switch (loop(0, 0)) + { + case LOOP_OK: + /* nothing to do but compilers like a complete enum */ + break; + + case LOOP_EMPTY: + /* Empty code resets status */ + lastval = 0; + break; + + case LOOP_ERROR: ret = SOURCE_ERROR; + break; + } } funcstack = funcstack->prev; sourcelevel--; |