Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jun 2014 18:00:56 +0200
From:      Polytropon <freebsd@edvax.de>
To:        mexas@bris.ac.uk
Cc:        freebsd-questions@freebsd.org
Subject:   Re: quotes around YES or NO are not necessary in /etc/rc.conf?
Message-ID:  <20140610180056.82404fd5.freebsd@edvax.de>
In-Reply-To: <201406101202.s5AC2Qo9066628@mech-anton240.men.bris.ac.uk>
References:  <201406101202.s5AC2Qo9066628@mech-anton240.men.bris.ac.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 10 Jun 2014 13:02:26 +0100 (BST), Anton Shterenlikht wrote:
> Am I right that quotes around YES or NO are
> not needed in /etc/rc.conf?

The file /etc/rc.conf basically is a Bourne shell script,
and it usually only contains variable=3Dvalue pairs, so the
rules for this construct apply: Quotes aren't needed if
the value is just a single word, or if spaces are properly
escaped, as you correctly assume:



> It seems both forms, e.g.:
>=20
> ntpd_enable=3D"YES"
> lpd_enable=3DYES
>=20
> are understood.

Also imagine things like:

	foo_flags=3DBLA\ MOO\ MEOW

Still it definitely looks better with quotes.

Also consider the following: If double quotes are used, you
can use evaluation within the quotes (even though you probably
don't do this inside /etc/rc.conf), and if single quotes are
used, things are associated 1:1, like:

	FOO=3D`/sbin/date "+%Y-%m-%d %H:%M:%S"`
	bar_flags=3D"set date =3D $FOO"
	baz_flags=3D'SYS$MANAGER'

This is consistent with "man sh". But note that /etc/rc.conf is
for sure not a place to run commands from. :-)



> I think quotes might be coming from
> incorrect reading of rc.conf(5).
> It has lines like:
>=20
>      rc_debug    (bool) If set to =E2=80=9CYES=E2=80=9D, enable output of=
 debug messages from
>=20
> or
>=20
>      rc_info     (bool) If set to =E2=80=9CNO=E2=80=9D, disable informati=
onal messages from
>=20
> however this is just quoting the special
> words from the rest of the sentence.
> The boolean value is either YES or NO.
> The quotes are not needed.

For YES and NO, they are not needed, but in my opinion, using
quotes for _any_ setting makes the whole thing consistent and
less error-prone (for missing a required quote, or worse, an
escape as shown above). The fact that rc.conf is just a shell
script isn't that clear, but read paragraph 2 of DESCRIPTION
in its manpage:

     The purpose of rc.conf is not to run commands or perform system startup
     actions directly.  Instead, it is included by the various generic star=
tup
     scripts in /etc which conditionalize their internal actions according =
to
     the settings found there.

A few lines ater on:

     Options are set with ``name=3Dvalue'' assignments that use sh(1) synta=
x.

This is what "makes the rules". :-)

Additionally, note that the manpage does not use "..." to
emphasize a value _as_ a value (separating from the rest of
the sentence", but ``...'', which is definitely not sh syntax
and cannot be confused with either "..." (quoting with evaluation),
'...' (quoting without evaluation), or even `...` (subcommand
result).


--=20
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?20140610180056.82404fd5.freebsd>