From owner-freebsd-hackers@FreeBSD.ORG Sun Oct 10 05:24:17 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9942E1065673 for ; Sun, 10 Oct 2010 05:24:17 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from out-0.mx.aerioconnect.net (outp.internet-mail-service.net [216.240.47.239]) by mx1.freebsd.org (Postfix) with ESMTP id E0C1E8FC08 for ; Sun, 10 Oct 2010 05:24:16 +0000 (UTC) Received: from idiom.com (postfix@mx0.idiom.com [216.240.32.160]) by out-0.mx.aerioconnect.net (8.13.8/8.13.8) with ESMTP id o9A5OGlS014653 for ; Sat, 9 Oct 2010 22:24:16 -0700 X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (h-67-100-89-137.snfccasy.static.covad.net [67.100.89.137]) by idiom.com (Postfix) with ESMTP id 7A8812D601C for ; Sat, 9 Oct 2010 22:24:15 -0700 (PDT) Message-ID: <4CB14E2D.3070806@freebsd.org> Date: Sat, 09 Oct 2010 22:25:01 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org References: <1286397912.27308.40.camel@localhost.localdomain> <51B4504F-5AA4-47C5-BF23-FA51DE5BC8C8@vicor.com> <238E0B24-AA12-4684-9651-84DA665BE893@vicor.com> In-Reply-To: <238E0B24-AA12-4684-9651-84DA665BE893@vicor.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 216.240.47.51 Subject: Re: sysrc -- a sysctl(8)-like utility for managing /etc/rc.conf et. al. 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: Sun, 10 Oct 2010 05:24:17 -0000 Ah grasshoppers... /me wonders if anyone will get the full significance of that.. On 10/9/10 3:39 PM, Devin Teske wrote: > On Oct 9, 2010, at 1:25 PM, Garrett Cooper wrote: > > >> Why not just do... >> >> if [ "x$rc_conf_files" = x -o "x$varname" = x ] >> then >> return ${FAILURE-1} >> fi > I think you'll find (quite pleasantly) that if you intonate the lines... > > "rc_conf_files [is non-null] OR return failure" > "varname [is non-null] OR return failure" > > Sounds a lot better/cleaner than the intonation of the suggested replacement: > > "if x plus rc_conf_files expands to something that is not equal to x OR x plus the expansion of varname is not x then return failure" > For what it matters, I'v enever found the [ "x$foo" = "x" ] construct to be useful. the quoting seems to work for everything I've ever worked on. so "officially" I'd express it as: if [ -n "$rc_conf_files" -o -n "$varname" ] but if I were hacking I'd probably express it as if [ "$rc_conf_files" != "" ] || [ "$varname" != "" ] then ..... I also sometimes find the use of the (()) operator to be useful. Now One thing that should be bourne in mind (heh) is that as there is a 'usual' form of format for perl there is one for sh as well so it's not "polite" to make one's sh code look like perl. :-)