From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: First pass at zerr/zwarn sanity
Date: Mon, 2 Oct 2000 03:38:14 +0000 [thread overview]
Message-ID: <1001002033815.ZM20519@candle.brasslantern.com> (raw)
In-Reply-To: <20001001201841.B12600@dman.com>
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
prev parent reply other threads:[~2000-10-02 3:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-09-27 19:46 two append bugs? Clint Adams
2000-09-28 3:35 ` Bart Schaefer
2000-09-29 16:58 ` Use of zerr() vs. zwarn() Bart Schaefer
2000-09-30 16:42 ` Bart Schaefer
2000-10-02 0:18 ` Clint Adams
2000-10-02 3:38 ` Bart Schaefer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1001002033815.ZM20519@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).