explicit use of /etc/rc.d vs service

Chris Rees crees at FreeBSD.org
Thu Jan 24 20:32:31 UTC 2013


On 24 January 2013 20:13, Warren Block <wblock at wonkity.com> wrote:
> On Thu, 24 Jan 2013, Eitan Adler wrote:
>
>> On 24 January 2013 10:36, Warren Block <wblock at wonkity.com> wrote:
>>>
>>> On Wed, 23 Jan 2013, Eitan Adler wrote:
>>>
>>>> Would anyone object to a patch which converts uses of
>>>> "/etc/rc.d/daemon start" to "service daemon start" and the like?
>>>> I would like to see service(1) become the standard interface to using
>>>> services.
>>>
>>>
>>>
>>> Agreed.  service(1) puts things in one place and abstracts them.  Also,
>>> it's
>>> less typing and easier to autocomplete.
>
>
> I did not look at this in detail, but would suggest that the unquoted
> rc.conf examples should be quoted as the preferred form:
>
>
>> --- a/en_US.ISO8859-1/books/handbook/config/chapter.xml
>> +++ b/en_US.ISO8859-1/books/handbook/config/chapter.xml
>> @@ -679,7 +679,7 @@ HOME=/var/log
>
> ...
>
>>     <para>It is easy to check if a service is enabled in
>>       <filename>/etc/rc.conf</filename> by running the appropriate
>> @@ -720,7 +720,7 @@ HOME=/var/log
>>       <command>sshd</command> is in fact enabled in
>>       <filename>/etc/rc.conf</filename> by running:</para>
>>
>> -    <screen>&prompt.root; <userinput>/etc/rc.d/sshd rcvar</userinput>
>> +    <screen>&prompt.root; <userinput>service sshd rcvar</userinput>
>> # sshd
>> $sshd_enable=YES</screen>
>>
>> @@ -734,7 +734,7 @@ $sshd_enable=YES</screen>
>>       <option>status</option> option is available.  For instance to
>>       verify that <command>sshd</command> is actually started:</para>
>
>
> Should be sshd_enable="YES" in both places.

Why?

Useless quotes are not useful, and the habit of using them everywhere
is actively harmful.

For example, our make is perfectly happy with:

.if ${ARCH} == "amd64"
and
.if ${ARCH} == amd64

even though the former is actually incorrect.

However, if an unsuspecting person does the same in GNU Make,

ifeq ($(ARCH),"amd64")

they are in for a shock, and spend a while wondering why it doesn't work [1].

Also, have a look in rc.subr;

[crees at pegasus]~% grep '="[^[:space:]]*$' /etc/rc.subr | wc -l #
Uselessly quoted
      36
[crees at pegasus]~% grep '=[^"[:space:]]*$' /etc/rc.subr | wc -l # Not quoted
     114

Of the 36 lines that are apparently uselessly quoted, 16 contain
variables, so that's OK;

[crees at pegasus]~% grep '="[^[:space:]]*\$[^[:space:]]*$' /etc/rc.subr | wc -l
       16

and finally, show all the lines that are truly uselessly quoted:

[crees at pegasus]~% grep '="[^\$|&;<>()`[:space:]]*$' /etc/rc.subr | wc -l
      13

Sorry to sound a little OCD, but overquoting bothers me, and it
doesn't fit with rc.subr style.  (Let's ignore defaults/rc.conf for
now...)

Chris

[1] http://www.bayofrum.net/~crees/scratch/gmake-quotes.mk


More information about the freebsd-doc mailing list