From owner-freebsd-hackers@FreeBSD.ORG Tue May 16 21:51: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 EAD5816A469 for ; Tue, 16 May 2006 21:51:53 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from koef.zs64.net (koef.zs64.net [213.238.47.30]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5802243D45 for ; Tue, 16 May 2006 21:51:52 +0000 (GMT) (envelope-from stb@lassitu.de) Received: (from stb@koef.zs64.net) (authenticated) by koef.zs64.net (8.13.6/8.13.6) with ESMTP id k4GLpceK048728 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO); Tue, 16 May 2006 23:51:50 +0200 (CEST) (envelope-from stb@lassitu.de) In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v750) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <83FEAC4F-7F0D-430D-B1FB-D02CA721E2AC@lassitu.de> Content-Transfer-Encoding: 7bit From: Stefan Bethke Date: Tue, 16 May 2006 23:51:15 +0200 To: "Ricardo A. Reis" X-Mailer: Apple Mail (2.750) Cc: freebsd-hackers@freebsd.org Subject: Re: kldfind 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: Tue, 16 May 2006 21:51:54 -0000 Am 16.05.2006 um 23:15 schrieb Ricardo A. Reis: > I writed one script for find freebsd kernel modules, ... > [ricardo@myfreebsd:~/kldfind] # ./kldfind -h > Options: > -c -- find all matchs for category > -s -- string match ... > http://ricardo.epm.br/freebsd/script/ It's a nice little script, but I think it can be improved in a few aspects. Just off the top of my head: Exit codes: plase see sysexits(3) for a number of well-defined exit codes and their meanings. If your script is invoked with the -c or -s switch, but no search term was provided, help() will exit with 0; EX_USAGE (64) would be more appropriate. Options handling: FreeBSD (and Posix) provide getopt(1) for options processing; while your script doesn't use options as such (-c, -h, and -s are really sub-commands, not options here), it's probably worthwile to use the standard functionality anyway. Functionality: inside the loop in search(), the sleep is superflous. Also, using exit inside the loop will terminate the script. With the current construction, only the first component of the KLD search path will ever be searched. It is debatable whether not finding any matching modules should be an error. Output format: there's no easy way to post-process the search results with a script. A pretty print version of the output is nice, but for a system utility, the default should be something that can be easily post-processed with another script. Stefan -- Stefan Bethke Fon +49 170 346 0140