From owner-freebsd-hackers@FreeBSD.ORG Wed May 24 18:17:53 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8A3AB16AAE9 for ; Wed, 24 May 2006 18:17:53 +0000 (UTC) (envelope-from rick@kiwi-computer.com) Received: from kiwi-computer.com (megan.kiwi-computer.com [63.224.10.3]) by mx1.FreeBSD.org (Postfix) with SMTP id B9DF443D58 for ; Wed, 24 May 2006 18:17:52 +0000 (GMT) (envelope-from rick@kiwi-computer.com) Received: (qmail 93744 invoked by uid 2001); 24 May 2006 18:17:51 -0000 Date: Wed, 24 May 2006 13:17:51 -0500 From: "Rick C. Petty" To: "Ricardo A. Reis" Message-ID: <20060524181751.GA92607@megan.kiwi-computer.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i Cc: "freebsd-hackers@freebsd.org" Subject: Re: kldfind, updated for version 0.56 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 May 2006 18:17:55 -0000 On Sun, May 21, 2006 at 02:28:29PM -0300, Ricardo A. Reis wrote: > > First about exit codes, when program is executed without options, > how this must return ? > kldunload and kldload not return the same exit codes, > > [ricardo@myfreebsd:~/kldfind] # kldload > usage: kldload [-v] file ... > zsh: 48524 exit 1 kldload > > [ricardo@myfreebsd:~/kldfind] # kldunload > usage: kldunload [-fv] -i id ... > kldunload [-fv] [-n] name ... > zsh: 48539 exit 64 kldunload > > [ricardo@myfreebsd:~/kldfind] # ./kldfind-v056 > usage: kldfind-v056 [-chqsv] ... > > In kldfind i return 0 See the manpage for sysexits(3). Both should return EX_USAGE (64) in this case. You should only return EX_OK (0) if the command was successful. If you're spitting out usage text, return EX_USAGE. Also by glancing at your usage string, it's not apparent that specifying no options is an invalid usage. Without reading through your script, I'm not sure which options are optional or which are required. I read "[-chqsv]" meaning use any of those options in any combination, or no options whatsoever. Consider something like either: kldfind -c | -s | -h [-qv] modulename ... or a multi-line usage (e.g. something like bsdlabel(1)): kldfind [-qv] -c category ... kldfind [-qv] -s string ... kldfind [-qv] -h Personally, I'd prefer clarity over brevity. Just my 3 cents, -- Rick C. Petty