From owner-freebsd-questions@FreeBSD.ORG Tue Jun 10 16:01:07 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 15FAF23A for ; Tue, 10 Jun 2014 16:01:07 +0000 (UTC) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CC2062573 for ; Tue, 10 Jun 2014 16:01:06 +0000 (UTC) Received: from r56.edvax.de (port-92-195-64-166.dynamic.qsc.de [92.195.64.166]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx02.qsc.de (Postfix) with ESMTPS id 6AAC02764A; Tue, 10 Jun 2014 18:00:57 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id s5AG0use001984; Tue, 10 Jun 2014 18:00:56 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Tue, 10 Jun 2014 18:00:56 +0200 From: Polytropon To: mexas@bris.ac.uk 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> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jun 2014 16:01:07 -0000 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, ...