From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 1 18:02:58 2005 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 19D8516A41F; Mon, 1 Aug 2005 18:02:58 +0000 (GMT) (envelope-from keramida@linux.gr) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.93]) by mx1.FreeBSD.org (Postfix) with ESMTP id 24EB743D45; Mon, 1 Aug 2005 18:02:56 +0000 (GMT) (envelope-from keramida@linux.gr) Received: from beatrix.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226]) by aiolos.otenet.gr (8.13.4/8.13.4/Debian-1) with SMTP id j71I2soG010942; Mon, 1 Aug 2005 21:02:54 +0300 Received: from beatrix.daedalusnetworks.priv (localhost [127.0.0.1]) by beatrix.daedalusnetworks.priv (8.13.3+Sun/8.13.3) with ESMTP id j71I2sgG001213; Mon, 1 Aug 2005 21:02:54 +0300 (EEST) Received: (from keramida@localhost) by beatrix.daedalusnetworks.priv (8.13.3+Sun/8.13.3/Submit) id j71I2s5V001212; Mon, 1 Aug 2005 21:02:54 +0300 (EEST) Date: Mon, 1 Aug 2005 21:02:54 +0300 From: Giorgos Keramidas To: John Baldwin Message-ID: <20050801180254.GB1176@beatrix.daedalusnetworks.priv> References: <64511.68.95.232.238.1122917387.squirrel@68.95.232.238> <200508011355.19274.jhb@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200508011355.19274.jhb@FreeBSD.org> Cc: freebsd-hackers@freebsd.org Subject: Re: [patch] rc.d cleanup 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: Mon, 01 Aug 2005 18:02:58 -0000 On 2005-08-01 13:55, John Baldwin wrote: >On Monday 01 August 2005 01:29 pm, diz@linuxpowered.com wrote: >> 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 >> [...] >> } > > 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. Ditto. The if/then blocks may look superficial at first and entirely redundant, but they really work much better then code like this: [ -f foo ] || bar has to be extended to form a multiline statement. Now, I know that one can always write: [ -f foo ] || { [ -d bar ] && { blah } } But this quickly gets too ugly for my taste. The equivalent if/then blocks: if [ ! -f foo ]; then if [ -d bar ]; then blah fi fi or even, the similar: if [ ! -f foo ] && [ -d bar ]; then blah fi Look much much prettier to the eyes of one who knows how to read both shell scripts and C code. - Giorgos