Date: Sun, 10 Oct 2010 23:36:10 -0400 From: Garance A Drosihn <drosih@rpi.edu> To: Devin Teske <dteske@vicor.com> Cc: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> Subject: Re: sysrc -- a sysctl(8)-like utility for managing /etc/rc.conf et. al. Message-ID: <4CB2862A.1070207@rpi.edu> In-Reply-To: <12CA8898-95C0-465E-9560-F7184D126903@vicor.com> References: <1286397912.27308.40.camel@localhost.localdomain> <AANLkTikoohMo5ng-RM3tctTH__P6cqhQpm=FPhSE9mMg@mail.gmail.com> <51B4504F-5AA4-47C5-BF23-FA51DE5BC8C8@vicor.com> <AANLkTim=BLkd229vdEst8U0ugpq3UsHPxjZZp2qaJxH-@mail.gmail.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>
next in thread | previous in thread | raw e-mail | index | archive | help
On 10/10/10 8:46 PM, Devin Teske wrote: > On Oct 10, 2010, at 4:51 PM, Garance A Drosihn <drosih@rpi.edu > <mailto:drosih@rpi.edu>> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4CB2862A.1070207>