Subject: Re: ifconfig error handling
To: None <tech-net@NetBSD.org>
From: David Young <firstname.lastname@example.org>
Date: 08/30/2006 18:32:57
On Thu, Aug 31, 2006 at 09:12:58AM +1000, Daniel Carosone wrote:
> On Wed, Aug 30, 2006 at 05:54:09PM -0500, David Young wrote:
> > Browsing the source, I do not understand why any number of warn() and
> > warnx() calls are not err(EXIT_FAILURE,) and errx(EXIT_FAILURE,), instead.
> WAG: so that it will continue processing multiple configuration
> settings on the one command line, even when an earlier one fails?
I consider that a bug, also! :-)
The "real" fix is to make ifconfig try to apply each setting on the
command line, and if it cannot apply a setting, roll back all of the
prior settings before quitting with exit code 1. This is an interesting
but large project that I am not going to do right now.
I can think of two "stopgap" fixes. One is to change warn()/warnx()
to err()/errx(). The other is to warn()/warnx(), but set a flag that
tells ifconfig to exit(EXIT_FAILURE) at the end. The latter fix could
be gross to program and to maintain.
A dissatisfying workaround is to check in scripts and such for text
on the standard error output. A wrapper, eifconfig, could be used for
ifconfig "$@" 2> /tmp/ifconfig.$$
test ! -s /tmp/ifconfig.$$
cat /tmp/ifconfig.$$ >&2
David Young OJC Technologies
email@example.com Urbana, IL * (217) 278-3933