From owner-freebsd-bugs@FreeBSD.ORG Sat Mar 15 01:10:02 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CFBF510656C0 for ; Sat, 15 Mar 2008 01:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B88448FC13 for ; Sat, 15 Mar 2008 01:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m2F1A2Mv074539 for ; Sat, 15 Mar 2008 01:10:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m2F1A20X074538; Sat, 15 Mar 2008 01:10:02 GMT (envelope-from gnats) Date: Sat, 15 Mar 2008 01:10:02 GMT Message-Id: <200803150110.m2F1A20X074538@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: bruce@cran.org.uk Cc: Subject: Re: bin/112303: route(8): 'route get' returns wrong exit code if no match X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: bruce@cran.org.uk List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Mar 2008 01:10:03 -0000 The following reply was made to PR bin/112303; it has been noted by GNATS. From: bruce@cran.org.uk To: bug-followup@freebsd.org Cc: cpetrie@xcalibre.co.uk Subject: Re: bin/112303: route(8): 'route get' returns wrong exit code if no match Date: Sat, 15 Mar 2008 01:02:14 +0000 --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In route.c in newroute() there's a call to exit(0) if the command was 'get'. Since rtmsg() always gets called and returns 0 on success and -1 on failure, it's possible to exit with a suitable exit code by calling exit(ret != 0) instead, as is done at the end of newroute(). -- Bruce --fUYQa+Pmc3FrFX/N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="route.c.diff" --- route_old.c 2008-03-15 00:42:34.000000000 +0000 +++ route.c 2008-03-15 00:40:41.000000000 +0000 @@ -748,7 +748,7 @@ break; } if (*cmd == 'g') - exit(0); + exit(ret != 0); if (!qflag) { oerrno = errno; (void) printf("%s %s %s", cmd, ishost? "host" : "net", dest); --fUYQa+Pmc3FrFX/N--