Re: quotes around YES or NO are not necessary in /etc/rc.conf?

看板FB_questions作者時間11年前 (2014/06/11 02:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
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.: > = > ntpd_enable=3D"YES" > lpd_enable=3DYES > = > 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: > = > rc_debug (bool) If set to =E2=80=9CYES=E2=80=9D, enable output of= debug messages from > = > or > = > rc_info (bool) If set to =E2=80=9CNO=E2=80=9D, disable informati= onal messages from > = > 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). -- = Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
文章代碼(AID): #1JbqVWj- (FB_questions)
文章代碼(AID): #1JbqVWj- (FB_questions)