Date: Mon, 1 Aug 2005 13:55:18 -0400 From: John Baldwin <jhb@FreeBSD.org> To: freebsd-hackers@freebsd.org Subject: Re: [patch] rc.d cleanup Message-ID: <200508011355.19274.jhb@FreeBSD.org> In-Reply-To: <64511.68.95.232.238.1122917387.squirrel@68.95.232.238> References: <64511.68.95.232.238.1122917387.squirrel@68.95.232.238>
next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 01 August 2005 01:29 pm, diz@linuxpowered.com wrote: > Hi there, > > This is my first patch to this project. > This is the first of many patches to come actually, but I need to find a > sponsor to guide me, and review what I submit. The patch is kinda big, and > far reaching in terms of altering almost every rc.d script. > > This patch effects most of the rc.d scripts that utilize simple IF > statements, converting them to logical AND/OR's instead. For example: > > if [ ! -f foo ] > then > bar > fi > > Would simply become: > > [ -f foo ] || bar > > The exception (but not the rule) is for any situation where ELIF/ELSE is > required. In other words any exclusive conditional situations. > > I also applied this notion to many simple blocks of code wrapped around > non-exclusive IF statements, such as: > > [ -f foo ] && { > command-list > [...] > } > > This has the result of reducing the size of the shell code, and reducing > the problem of over-engineering that plagues many scripts. I found quite > many places where there were one-line situations wrapped up in multi-line > IF statements, which I was compelled to eliminate. Further more, as I > audited the scripts, I noticed that in several places this style of > scripting was already used in various places. So I feel this make the > entire span of scripts uniform. > > > -Jon Disnard The argument I would have against this is that it is a lot easier to read the 'if foo; then ; fi' style, esp. for folks used to using C, etc. Shell scripts don't need to be overly obfuscated. -- John Baldwin <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508011355.19274.jhb>