about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--Src/builtin.c7
-rw-r--r--Src/exec.c27
-rw-r--r--Src/glob.c3
-rw-r--r--Src/signals.c3
-rw-r--r--Src/utils.c3
6 files changed, 28 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index d00932858..3c18dbc30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2000-10-02  Bart Schaefer  <schaefer@zsh.org>
+
+	* 12869: Src/builtin.c, Src/exec.c, Src/glob.c, Src/signals.c,
+	Src/utils.c: Change several zerr() to zwarn(), either because
+	errflag was immediately cleared after calling zerr(), or to make
+	builtin commands fail normally (with nonzero exit status) rather
+	than aborting all the way back to top level.
+
 2000-10-01  Clint Adams  <schizo@debian.org>
 
 	* unposted: Src/Zle/compresult.c: remove unused variable declaration.
diff --git a/Src/builtin.c b/Src/builtin.c
index efbbd20d9..afd140d3c 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -291,7 +291,7 @@ execbuiltin(LinkList args, Builtin bn)
 	    if (*arg) {
 		if(*arg == Meta)
 		    *++arg ^= 32;
-		zerr("bad option: -%c", NULL, *arg);
+		zwarn("bad option: -%c", NULL, *arg);
 		return 1;
 	    }
 	    arg = (char *) ugetnode(args);
@@ -3078,10 +3078,9 @@ err:
 	if(quiet) {
 	    zoptarg = metafy(optbuf, lenoptbuf, META_DUP);
 	} else {
-	    zerr(*p == '?' ? "bad option: -%c" :
-		"argument expected after -%c option", NULL, opch);
+	    zwarn(*p == '?' ? "bad option: -%c" :
+		  "argument expected after -%c option", NULL, opch);
 	    zoptarg=ztrdup("");
-	    errflag = 0;
 	}
 	return 0;
     }
diff --git a/Src/exec.c b/Src/exec.c
index 4a8aab335..d0787f222 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1824,8 +1824,8 @@ execcmd(Estate state, int input, int output, int how, int last1)
 	    }
 	    if (!(hn = builtintab->getnode(builtintab, cmdarg))) {
 		if (cflags & BINF_BUILTIN) {
-		    zerr("no such builtin: %s", cmdarg, 0);
-		    errflag = lastval = 1;
+		    zwarn("no such builtin: %s", cmdarg, 0);
+		    lastval = 1;
 		    return;
 		}
 		break;
@@ -2085,7 +2085,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		execerr();
 	    }
 	    if (isset(RESTRICTED) && IS_WRITE_FILE(fn->type)) {
-		zerr("writing redirection not allowed in restricted mode", NULL, 0);
+		zwarn("writing redirection not allowed in restricted mode", NULL, 0);
 		execerr();
 	    }
 	    if (unset(EXECOPT))
@@ -2097,7 +2097,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		    closemnodes(mfds);
 		    fixfds(save);
 		    if (errno != EINTR)
-			zerr("%e", NULL, errno);
+			zwarn("%e", NULL, errno);
 		    execerr();
 		}
 		addfd(forked, save, mfds, fn->fd1, fil, 0);
@@ -2113,7 +2113,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		    closemnodes(mfds);
 		    fixfds(save);
 		    if (errno != EINTR)
-			zerr("%e: %s", fn->name, errno);
+			zwarn("%e: %s", fn->name, errno);
 		    execerr();
 		}
 		addfd(forked, save, mfds, fn->fd1, fil, 0);
@@ -2152,7 +2152,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		    fixfds(save);
 		    if (fn->fd2 != -2)
 		    	sprintf(fdstr, "%d", fn->fd2);
-		    zerr("%s: %e", fn->fd2 == -2 ? "coprocess" : fdstr, errno);
+		    zwarn("%s: %e", fn->fd2 == -2 ? "coprocess" : fdstr, errno);
 		    execerr();
 		}
 		addfd(forked, save, mfds, fn->fd1, fil, fn->type == MERGEOUT);
@@ -2175,7 +2175,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		    closemnodes(mfds);
 		    fixfds(save);
 		    if (errno != EINTR)
-			zerr("%e: %s", fn->name, errno);
+			zwarn("%e: %s", fn->name, errno);
 		    execerr();
 		}
 		addfd(forked, save, mfds, fn->fd1, fil, 1);
@@ -2287,9 +2287,8 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		fflush(stdout);
 		if (save[1] == -2) {
 		    if (ferror(stdout)) {
-			zerr("write error: %e", NULL, errno);
+			zwarn("write error: %e", NULL, errno);
 			clearerr(stdout);
-			errflag = 0;
 		    }
 		} else
 		    clearerr(stdout);
@@ -3235,7 +3234,7 @@ loadautofn(Shfunc shf, int fksh, int autol)
     if (prog == &dummy_eprog) {
 	/* We're not actually in the function; decrement locallevel */
 	locallevel--;
-	zerr("%s: function definition file not found", shf->nam, 0);
+	zwarn("%s: function definition file not found", shf->nam, 0);
 	locallevel++;
 	popheap();
 	return NULL;
@@ -3258,7 +3257,7 @@ loadautofn(Shfunc shf, int fksh, int autol)
 	    execode(prog, 1, 0);
 	    shf = (Shfunc) shfunctab->getnode(shfunctab, n);
 	    if (!shf || (shf->flags & PM_UNDEFINED)) {
-		zerr("%s: function not defined by file", n, 0);
+		zwarn("%s: function not defined by file", n, 0);
 		popheap();
 		return NULL;
 	    }
@@ -3362,8 +3361,10 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
 
 	if (!(shf = (Shfunc) shfunctab->getnode(shfunctab,
 						(name = fname)))) {
-	    zerr("%s: function not defined by file", name, 0);
-	    if (!noreturnval)
+	    zwarn("%s: function not defined by file", name, 0);
+	    if (noreturnval)
+		errflag = 1;
+	    else
 		lastval = 1;
 	    popheap();
 	    scriptname = oldscriptname;
diff --git a/Src/glob.c b/Src/glob.c
index 28cf81f24..5e6283ed0 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -573,8 +573,7 @@ scanner(Complist q)
 			if (statfullpath(fn, &buf, !q->follow)) {
 			    if (errno != ENOENT && errno != EINTR &&
 				errno != ENOTDIR && !errflag) {
-				zerr("%e: %s", fn, errno);
-				errflag = 0;
+				zwarn("%e: %s", fn, errno);
 			    }
 			    continue;
 			}
diff --git a/Src/signals.c b/Src/signals.c
index 0a836f718..b397e1047 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -541,8 +541,7 @@ handler(int sig)
 		alarm(tmout - idle);
 	    else {
 		errflag = noerrs = 0;
-		zerr("timeout", NULL, 0);
-		errflag = 0;
+		zwarn("timeout", NULL, 0);
 		stopmsg = 1;
 		zexit(SIGALRM, 1);
 	    }
diff --git a/Src/utils.c b/Src/utils.c
index 4ec73d7be..4e5da893b 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -2404,12 +2404,11 @@ attachtty(pid_t pgrp)
 	    else {
 		if (errno != ENOTTY)
 		{
-		    zerr("can't set tty pgrp: %e", NULL, errno);
+		    zwarn("can't set tty pgrp: %e", NULL, errno);
 		    fflush(stderr);
 		}
 		opts[MONITOR] = 0;
 		ep = 1;
-		errflag = 0;
 	    }
 	}
     }