Date: Sun, 6 Aug 2017 15:31:30 +0200 From: Polytropon <freebsd@edvax.de> To: Manish Jain <bourne.identity@hotmail.com> Cc: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: Re: Is quoting necessary in /etc/rc.conf ? Message-ID: <20170806153130.1dbcefd0.freebsd@edvax.de> In-Reply-To: <VI1PR02MB120082575A858DA8685A40A0F6B40@VI1PR02MB1200.eurprd02.prod.outlook.com> References: <VI1PR02MB120082575A858DA8685A40A0F6B40@VI1PR02MB1200.eurprd02.prod.outlook.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 6 Aug 2017 11:00:03 +0000, Manish Jain wrote: > On my system, it works whether I put either of the following in rc.conf: > > xyz_enable="YES" > > Or, > > xyz_enable=YES > > Just wished to check whether an unquoted YES is completely equivalent > (and accepted) as a quoted YES ? Keep in mind /etc/rc.conf is basically a sh script. So the quoting rules of sh apply, and especially for the values YES and NO, it's completely equivalent. The general form is NAME=VALUE, and if VALUE contains spaces, quoting is needed, except you escape spaces. So foo_enable=YES is totally valid (no spaces), while both foo_flags="bar baz" and foo_flags=bar\ baz is valid as well (with spaces). If VALUE contains the $ sign or other special characters that might cause interpretation by /bin/sh at "parsing time", using the single quotes is possible: foo_currency='US$' For empty values, using foo_flags="" instead of foo_flags= looks "more logical", as "the empty value" can clearly be seen, instead of just missing the right-hand side of the association. In order to avoid confusion, using quotes for all arguments is suggested as per /etc/defaults/rc.conf ("system standard"), and this consistent form - even for the values that don't _require_ quotes, provides a clean view of that configuration file. That said, sticking with the "system standard" is never wrong. :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170806153130.1dbcefd0.freebsd>