Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: First pass at zerr/zwarn sanity
- X-seq: zsh-workers 12869
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: First pass at zerr/zwarn sanity
- Date: Mon, 2 Oct 2000 03:38:14 +0000
- In-reply-to: <20001001201841.B12600@xxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <20000927154646.B4971@xxxxxxxx> <1000928033550.ZM13657@xxxxxxxxxxxxxxxxxxxxxxx> <1000929165834.ZM14923@xxxxxxxxxxxxxxxxxxxxxxx> <20001001201841.B12600@xxxxxxxx>
On Oct 1, 8:18pm, Clint Adams wrote:
} Subject: Re: Use of zerr() vs. zwarn()
}
} I can't see any value to not doing it this way except perhaps in interactive
} contexts, and even then it's a bit counterintuitive.
This patch changes only zerr --> zwarn, and none the other way 'round. It
is possible that a script or function relies on the exit-if-redirect-fails
behavior of builtins, which after this patch need an explicit `|| return'
or the like; but otherwise nothing in this patch should affect a working
script or function. (Some non-working ones might begin running farther
than they previously had.)
See zsh-workers/12867 for discussion of other places that still might be
changable.
The only possibly-controversial change here is, I think, the last hunk of
exec.c. It preserves the zerr behavior when the caller has requested that
`lastval' not change.
Index: Src/builtin.c
===================================================================
@@ -291,7 +291,7 @@
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 @@
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;
}
Index: Src/exec.c
===================================================================
@@ -1824,8 +1824,8 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;
Index: Src/glob.c
===================================================================
@@ -573,8 +573,7 @@
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;
}
Index: Src/signals.c
===================================================================
@@ -541,8 +541,7 @@
alarm(tmout - idle);
else {
errflag = noerrs = 0;
- zerr("timeout", NULL, 0);
- errflag = 0;
+ zwarn("timeout", NULL, 0);
stopmsg = 1;
zexit(SIGALRM, 1);
}
Index: Src/utils.c
===================================================================
@@ -2405,12 +2405,11 @@
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;
}
}
}
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by:
Reverse Date,
Date,
Thread,
Author