From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 11 03:36:36 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 D77AB1065670 for ; Mon, 11 Oct 2010 03:36:36 +0000 (UTC) (envelope-from drosih@rpi.edu) Received: from smtp8.server.rpi.edu (smtp8.server.rpi.edu [128.113.2.228]) by mx1.freebsd.org (Postfix) with ESMTP id 971048FC12 for ; Mon, 11 Oct 2010 03:36:36 +0000 (UTC) Received: from gilead.netel.rpi.edu (gilead.netel.rpi.edu [128.113.124.121]) by smtp8.server.rpi.edu (8.13.1/8.13.1) with ESMTP id o9B3aAHZ005844; Sun, 10 Oct 2010 23:36:10 -0400 Message-ID: <4CB2862A.1070207@rpi.edu> Date: Sun, 10 Oct 2010 23:36:10 -0400 From: Garance A Drosihn User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.9) Gecko/20100722 Eudora/3.0.4 MIME-Version: 1.0 To: Devin Teske References: <1286397912.27308.40.camel@localhost.localdomain> <51B4504F-5AA4-47C5-BF23-FA51DE5BC8C8@vicor.com> <238E0B24-AA12-4684-9651-84DA665BE893@vicor.com> <4CB14E2D.3070806@freebsd.org> <663E0B47-9318-4C75-BAEB-5C4F9EAFFDD1@vicor.com> <4CB25198.4020209@rpi.edu> <12CA8898-95C0-465E-9560-F7184D126903@vicor.com> In-Reply-To: <12CA8898-95C0-465E-9560-F7184D126903@vicor.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Bayes-Prob: 0.0001 (Score 0) X-RPI-SA-Score: 1.40 (*) [Hold at 15.00] RATWARE_GECKO_BUILD,22490(-25) X-CanItPRO-Stream: outgoing X-Canit-Stats-ID: Bayes signature not available X-Scanned-By: CanIt (www . roaringpenguin . com) on 128.113.2.228 Cc: "freebsd-hackers@freebsd.org" 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: Mon, 11 Oct 2010 03:36:36 -0000 On 10/10/10 8:46 PM, Devin Teske wrote: > On Oct 10, 2010, at 4:51 PM, Garance A Drosihn > wrote: > >> The latter does not cause an error. Try it: >> >> # [ "-n" = x ] ; echo $? >> 1 >> >> # [ -e = "no" ] ; echo $? >> 1 >> >> # [ -e = -n ] ; echo $? >> 1 > > 1 is error. 0 is success. > -- Um, yes, true. I know that. What I'm saying is that the command works as you'd want it to work. It does not hit a parsing error. The double-quotes did not change how the command behaved. You deleted the context of what I was replying to when I said the above. Looking at the examples I gave there, it probably would have been clearer if I had typed the exact same command with and without the double-quotes. Eg: On 10/10/10 7:09 PM, Devin Teske wrote: > However, enclosing the argument (as the 'x$foo' > portion is really just the first argument to the > '[' built-in) in quotes: > > [ "$foo" = x ] > > makes it so that the expansion is taken as: > > [ "-n" = x ] > > rather than: > > [ -n = x ] > > The former not causing an error, while the latter does. Your second example does not cause an error. Try it: # [ "-n" = "-n" ] ; echo $? 0 # [ "-n" = x ] ; echo $? 1 Compared to the double-quote-less: # [ -n = "-n" ] ; echo $? 0 # [ -n = x ] ; echo $? 1 -- Garance