Subject: Re: ifconfig error handling
To: David Young <dyoung@pobox.com>
From: Liam J. Foy <liamfoy@sepulcrum.org>
List: tech-net
Date: 08/31/2006 01:06:41
On 31 Aug 2006, at 00:32, David Young wrote:

> 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! :-)

I would rather see it process options until an error is found and
return(exit) consistently with the correct value. At least, we *should*
make it return consistent values.

>
> 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
> that purpose:
>
>         #!/bin/sh
>         ifconfig "$@" 2> /tmp/ifconfig.$$
>         test ! -s /tmp/ifconfig.$$
>         rc=$?
>         cat /tmp/ifconfig.$$ >&2
>         rm /tmp/ifconfig.$$
>         exit $rc
>
> Dave
>
> -- 
> David Young             OJC Technologies
> dyoung@ojctech.com      Urbana, IL * (217) 278-3933

		---
		Liam J. Foy
		<liamjfoy@netbsd.org>