From owner-freebsd-hackers@FreeBSD.ORG Tue May 16 23:54:10 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 73C0216A426 for ; Tue, 16 May 2006 23:54:10 +0000 (UTC) (envelope-from ricardo_bsd@yahoo.com.br) Received: from smtp105.mail.mud.yahoo.com (smtp105.mail.mud.yahoo.com [209.191.85.215]) by mx1.FreeBSD.org (Postfix) with SMTP id 054CF43D46 for ; Tue, 16 May 2006 23:54:09 +0000 (GMT) (envelope-from ricardo_bsd@yahoo.com.br) Received: (qmail 27393 invoked from network); 16 May 2006 23:54:09 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; h=Received:Date:To:Subject:From:Organization:Cc:Content-Type:MIME-Version:References:Content-Transfer-Encoding:Message-ID:In-Reply-To:User-Agent; b=wOd1x9c1lUAn75kMkd3xMkCGy9mR63mm1FxSmkk0bfcB0DMZ/TTRmGESAoHSkm7Rl/p0fTdqPdqNCdhw3SVvC/rT6PLWHCqk4/VbkahtdC8ucbue2A4WxwLWZS9L0ckYnM8kzAE4GGlb5v7idHg1gdtFM0URVTLZBzJfeAH9QPY= ; Received: from unknown (HELO localhost) (ricardo?bsd@201.1.118.111 with login) by smtp105.mail.mud.yahoo.com with SMTP; 16 May 2006 23:54:08 -0000 Date: Tue, 16 May 2006 20:53:53 -0300 To: "Stefan Bethke" From: "Ricardo A. Reis" Organization: UNIFESP Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-1 MIME-Version: 1.0 References: <83FEAC4F-7F0D-430D-B1FB-D02CA721E2AC@lassitu.de> Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <83FEAC4F-7F0D-430D-B1FB-D02CA721E2AC@lassitu.de> User-Agent: Opera Mail/9.00 (FreeBSD) X-Mailman-Approved-At: Wed, 17 May 2006 01:52:15 +0000 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 23:54:10 -0000 On Tue, 16 May 2006 18:51:15 -0300, Stefan Bethke wrote: > 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: Thanks, > > 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. I readed sysexits() and replace the return code for help(). > > 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. About getopt a resolved not use, this a little script with 3 sub-commands getopts is necessary for include one program in src ? > 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. Sorry for this, i add exit codes after writed man, now i change exit per return. > > 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. Is possible pre-formate output with output() using printf/awk. I update http://ricardo.epm.br/freebsd/script/kldfind/kldfind-v051 Thanks again, Ricardo A. Reis UNIFESP Unix and Network Admin _______________________________________________________ Abra sua conta no Yahoo! Mail: 1GB de espaço, alertas de e-mail no celular e anti-spam realmente eficaz. http://br.info.mail.yahoo.com/