Quantcast

Making use of set_rcvar.

classic Classic list List threaded Threaded
30 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Making use of set_rcvar.

Pawel Jakub Dawidek
Any objections?

        http://people.freebsd.org/~pjd/patches/set_rcvar.patch

This patch only changes scripts where set_rcvar can be used with no
arguments.

--
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Jilles Tjoelker
On Fri, Jan 06, 2012 at 03:13:03PM +0100, Pawel Jakub Dawidek wrote:
> Any objections?

> http://people.freebsd.org/~pjd/patches/set_rcvar.patch

> This patch only changes scripts where set_rcvar can be used with no
> arguments.

While this makes the scripts cleaner, it will lead to extra forks with
the current implementation of sh which will slow down boot to some
extent. The effect is small on x86 but may be large on embedded
platforms.

If I could change history, I would have forbidden calling a function
from a command substitution like that in the template. Instead, the
function should be called normally and should set the variable itself.
However, I think that cannot be changed anymore.

I have a fairly small patch to sh to eliminate the fork when expanding
$(set_rcvar). However, one could object that this does not add true new
capabilities but only a new notation to the part of the language that
executes without forks (because the function could write into a variable
instead of being command-substituted).

--
Jilles Tjoelker
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Pawel Jakub Dawidek
On Fri, Jan 06, 2012 at 04:17:40PM +0100, Jilles Tjoelker wrote:

> On Fri, Jan 06, 2012 at 03:13:03PM +0100, Pawel Jakub Dawidek wrote:
> > Any objections?
>
> > http://people.freebsd.org/~pjd/patches/set_rcvar.patch
>
> > This patch only changes scripts where set_rcvar can be used with no
> > arguments.
>
> While this makes the scripts cleaner, it will lead to extra forks with
> the current implementation of sh which will slow down boot to some
> extent. The effect is small on x86 but may be large on embedded
> platforms.
That was my concern as well, but I was under impression that using
set_rcvar is preferred. I'm fine either way, but would like it to be
consistent across system startup scripts. I like using set_rcvar as it
eliminates typing name in one more place. Very handy when you create
your own script by changing existing one.

> If I could change history, I would have forbidden calling a function
> from a command substitution like that in the template. Instead, the
> function should be called normally and should set the variable itself.
> However, I think that cannot be changed anymore.
>
> I have a fairly small patch to sh to eliminate the fork when expanding
> $(set_rcvar). However, one could object that this does not add true new
> capabilities but only a new notation to the part of the language that
> executes without forks (because the function could write into a variable
> instead of being command-substituted).
Wouldn't it be helpful to define name before loading rc.subr? This would
make the scripts less pretty, though.

--
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

dougb
In reply to this post by Pawel Jakub Dawidek
On 01/06/2012 06:13, Pawel Jakub Dawidek wrote:
> Any objections?
>
> http://people.freebsd.org/~pjd/patches/set_rcvar.patch
>
> This patch only changes scripts where set_rcvar can be used with no
> arguments.

Please don't do this.

Jilles already pointed out the important reason, it adds pointless
forks. I suggested a long time ago that we remove set_rcvar altogether
but I got a lot of resistance to it, and never pursued it. Perhaps it's
time to revisit that.

In regards to your concern about not having to type the name of the
script when copying to create a new one, you can't really be serious
about that? If so, let me introduce you to this revolutionary thing
called "search and replace."

If you really need to make this simpler for copy/paste purposes in
http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/rc-scripts.html
I recommend using:

rcvar=${name}_enable

The microsecond it takes to dereference that is an acceptable cost to
making the copy/paste issue more palatable. This is particularly
important in the ports area since there is so much copy/paste that goes
on in that sphere.


Doug

--

        You can observe a lot just by watching. -- Yogi Berra

        Breadth of IT experience, and depth of knowledge in the DNS.
        Yours for the right price.  :)  http://SupersetSolutions.com/

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Pawel Jakub Dawidek
On Fri, Jan 06, 2012 at 05:05:58PM -0800, Doug Barton wrote:

> On 01/06/2012 06:13, Pawel Jakub Dawidek wrote:
> > Any objections?
> >
> > http://people.freebsd.org/~pjd/patches/set_rcvar.patch
> >
> > This patch only changes scripts where set_rcvar can be used with no
> > arguments.
>
> Please don't do this.
>
> Jilles already pointed out the important reason, it adds pointless
> forks. I suggested a long time ago that we remove set_rcvar altogether
> but I got a lot of resistance to it, and never pursued it. Perhaps it's
> time to revisit that.
It is a total mess now then and it is definiately not intuitive when
there are much more bad examples than good ones:

        % grep -r ^rcvar /usr/src/etc/rc.d | grep set_rcvar | wc -l
              66
        % grep -r ^rcvar /usr/src/etc/rc.d | grep -v set_rcvar | wc -l
              34

> In regards to your concern about not having to type the name of the
> script when copying to create a new one, you can't really be serious
> about that? If so, let me introduce you to this revolutionary thing
> called "search and replace."

Do you really expect me to comment this?

--
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

dougb
On 01/07/2012 03:25, Pawel Jakub Dawidek wrote:

> On Fri, Jan 06, 2012 at 05:05:58PM -0800, Doug Barton wrote:
>> On 01/06/2012 06:13, Pawel Jakub Dawidek wrote:
>>> Any objections?
>>>
>>> http://people.freebsd.org/~pjd/patches/set_rcvar.patch
>>>
>>> This patch only changes scripts where set_rcvar can be used with no
>>> arguments.
>>
>> Please don't do this.
>>
>> Jilles already pointed out the important reason, it adds pointless
>> forks. I suggested a long time ago that we remove set_rcvar altogether
>> but I got a lot of resistance to it, and never pursued it. Perhaps it's
>> time to revisit that.
>
> It is a total mess now then and it is definiately not intuitive when
> there are much more bad examples than good ones:

I agree, which is why I previously proposed assigning them all directly
when possible (which is in almost all cases). If no one speaks up
opposing this idea in the next few days I'm still prepared to proceed.

>> In regards to your concern about not having to type the name of the
>> script when copying to create a new one, you can't really be serious
>> about that? If so, let me introduce you to this revolutionary thing
>> called "search and replace."
>
> Do you really expect me to comment this?

Well I don't know, I thought you were being funny in your post, so I was
trying to respond in kind. Sorry if the humor missed the mark.


Doug

--

        You can observe a lot just by watching. -- Yogi Berra

        Breadth of IT experience, and depth of knowledge in the DNS.
        Yours for the right price.  :)  http://SupersetSolutions.com/

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Pawel Jakub Dawidek
On Sat, Jan 07, 2012 at 02:38:23PM -0800, Doug Barton wrote:

> On 01/07/2012 03:25, Pawel Jakub Dawidek wrote:
> > On Fri, Jan 06, 2012 at 05:05:58PM -0800, Doug Barton wrote:
> >> On 01/06/2012 06:13, Pawel Jakub Dawidek wrote:
> >>> Any objections?
> >>>
> >>> http://people.freebsd.org/~pjd/patches/set_rcvar.patch
> >>>
> >>> This patch only changes scripts where set_rcvar can be used with no
> >>> arguments.
> >>
> >> Please don't do this.
> >>
> >> Jilles already pointed out the important reason, it adds pointless
> >> forks. I suggested a long time ago that we remove set_rcvar altogether
> >> but I got a lot of resistance to it, and never pursued it. Perhaps it's
> >> time to revisit that.
> >
> > It is a total mess now then and it is definiately not intuitive when
> > there are much more bad examples than good ones:
>
> I agree, which is why I previously proposed assigning them all directly
> when possible (which is in almost all cases). If no one speaks up
> opposing this idea in the next few days I'm still prepared to proceed.
Don't forget to update documentation (rc(8)).

--
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Hiroki Sato
In reply to this post by dougb
Doug Barton <[hidden email]> wrote
  in <[hidden email]>:

do> On 01/07/2012 03:25, Pawel Jakub Dawidek wrote:
do> > On Fri, Jan 06, 2012 at 05:05:58PM -0800, Doug Barton wrote:
do> >> On 01/06/2012 06:13, Pawel Jakub Dawidek wrote:
do> >>> Any objections?
do> >>>
do> >>> http://people.freebsd.org/~pjd/patches/set_rcvar.patch
do> >>>
do> >>> This patch only changes scripts where set_rcvar can be used with no
do> >>> arguments.
do> >>
do> >> Please don't do this.
do> >>
do> >> Jilles already pointed out the important reason, it adds pointless
do> >> forks. I suggested a long time ago that we remove set_rcvar altogether
do> >> but I got a lot of resistance to it, and never pursued it. Perhaps it's
do> >> time to revisit that.
do> >
do> > It is a total mess now then and it is definiately not intuitive when
do> > there are much more bad examples than good ones:
do>
do> I agree, which is why I previously proposed assigning them all directly
do> when possible (which is in almost all cases). If no one speaks up
do> opposing this idea in the next few days I'm still prepared to proceed.

 I am always wondering if defining $rcvar as "${name}_enable" at the
 end of load_rc_config() when $rcvar is undefined is bad idea.

 Is there any problem with removing rcvar=... in individual rc.d
 scripts except for non-standard ones (empty or different from
 ${name}_enable)?  It looks simpler than writing the same line
 "rcvar=${name}_enable" many times in various places.

-- Hiroki

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

dougb
On 01/07/2012 15:12, Hiroki Sato wrote:
>  I am always wondering if defining $rcvar as "${name}_enable" at the
>  end of load_rc_config() when $rcvar is undefined is bad idea.
>
>  Is there any problem with removing rcvar=... in individual rc.d
>  scripts except for non-standard ones (empty or different from
>  ${name}_enable)?  It looks simpler than writing the same line
>  "rcvar=${name}_enable" many times in various places.

This sounds like a great idea in theory, but in practice it doesn't work
out, for 2 reasons. First, we have a lot of scripts in the base (about
1/3) that rely on the lack of any rcvar meaning that it gets run
unconditionally. In order to provide backwards compatibility we'd have
to add code to enable things by default that were previously unset.
That's not hard to do, but ....

The other reason is that for ports, the scripts generally look like this:

load_rc_config foo

: ${foo_enable:=NO}

See the problem?

There are ways around both of these issues, but they involve much more
dramatic changes that I don't think buy us much, if anything. There are
already a large'ish number of things that are repeated in each rc.d
script, so leaving this one in doesn't hurt anything. Whereas removing
the forks caused by calling set_rcvar actually gains us a shorter boot
time.*

Attached is a patch that does what I suggested a long time ago, removes
set_rcvar() entirely and assigns each rcvar statically. I'll commit this
in a few days if no one objects. (Note, it can't be committed yet
because the scripts in ports that call set_rcvar() have to be modified
first.)


Doug

* Yes, I know that we're only gaining a second, maybe two. But each time
we do something to improve the boot time the cumulative effect is what
we're after.

--

        You can observe a lot just by watching. -- Yogi Berra

        Breadth of IT experience, and depth of knowledge in the DNS.
        Yours for the right price.  :)  http://SupersetSolutions.com/


_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"

rcd-no-set_rcvar.diff (24K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Stefan Esser-3
Am 09.01.2012 00:12, schrieb Doug Barton:
> Attached is a patch that does what I suggested a long time ago, removes
> set_rcvar() entirely and assigns each rcvar statically. I'll commit this
> in a few days if no one objects. (Note, it can't be committed yet
> because the scripts in ports that call set_rcvar() have to be modified
> first.)
[...]

> Index: rc.d/nscd
> ===================================================================
> --- rc.d/nscd (revision 229825)
> +++ rc.d/nscd (working copy)
> @@ -19,7 +19,7 @@
>  . /etc/rc.subr
>
>  name="nscd"
> -rcvar=`set_rcvar`
> +rcvar="nscd_enable"

Why not generally use

        rcvar="${name}_enable"

instead of (e.g.)

        rcvar="nscd_enable"

in all scripts *in your patch set*, for which the outcome is the same?

All except for sendmail_submit_enable, sendmail_outbound_enable,
nfs_server_enable, moused_${2}_enable and clear_tmp_enable.

But for nfsd vs. nfs_server and cleartmp vs. clear_tmp it might be a
good idea to modify $name to match the value of the _enable parameter,
anyway.
Then only the special cases sendmail_*_enable and moused_*_enable would
persist.

The use of "${name}_enable" does not add measurable overhead, but that
way more of an existing script might be used as a prototype unchanged.

But using ${name}_enable enforces the use of an enable parameter that
actually is based on $name, not a slight variation thereof (ISTR such
cases existed and had to be fixed to avoid confusion).

Regards, STefan
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

dougb
On 01/09/2012 01:40, Stefan Esser wrote:

> Am 09.01.2012 00:12, schrieb Doug Barton:
>> Attached is a patch that does what I suggested a long time ago, removes
>> set_rcvar() entirely and assigns each rcvar statically. I'll commit this
>> in a few days if no one objects. (Note, it can't be committed yet
>> because the scripts in ports that call set_rcvar() have to be modified
>> first.)
> [...]
>> Index: rc.d/nscd
>> ===================================================================
>> --- rc.d/nscd (revision 229825)
>> +++ rc.d/nscd (working copy)
>> @@ -19,7 +19,7 @@
>>  . /etc/rc.subr
>>
>>  name="nscd"
>> -rcvar=`set_rcvar`
>> +rcvar="nscd_enable"
>
> Why not generally use
>
> rcvar="${name}_enable"
>
> instead of (e.g.)
>
> rcvar="nscd_enable"
>
> in all scripts *in your patch set*, for which the outcome is the same?

Because there is no good reason to add an extra layer of indirection.
IMO we should actually dereference all instances of $name in the
scripts, but I don't want to create the churn without good reason.

> But for nfsd vs. nfs_server and cleartmp vs. clear_tmp it might be a
> good idea to modify $name to match the value of the _enable parameter,
> anyway.
> Then only the special cases sendmail_*_enable and moused_*_enable would
> persist.

That sounds great, are you going to handle all the compatibility shims,
through the next 2 major releases? These knobs are not just used
internally, they are in users' rc.conf[.local] files. Changing the
special cases shouldn't be done without a really good reason. The
purpose (in part) of having a distinct $rcvar value in the first place
is to deal with them.

> The use of "${name}_enable" does not add measurable overhead, but that
> way more of an existing script might be used as a prototype unchanged.

I understand what you're saying, and I know that the whole "use
variables wherever we can" thing is all '1337 and computer science'y,
but it's silly. The concept of a universal template that can be copied
and pasted for different services is a pipe dream. There are already
many things that need to be changed in the new script, and not updating
rcvar for a new script causes clear and obvious failure messages.

> But using ${name}_enable enforces the use of an enable parameter that
> actually is based on $name, not a slight variation thereof (ISTR such
> cases existed and had to be fixed to avoid confusion).

For all new scripts we enforce <file name> == PROVIDE == $name (and by
extension rcvar="${name}_enable"). That's all part and parcel of the
same code review, so there is no reason to believe that requiring use of
the variable is going to cause proper code review any better than
actually, you know, doing proper code review.


Doug

--

        You can observe a lot just by watching. -- Yogi Berra

        Breadth of IT experience, and depth of knowledge in the DNS.
        Yours for the right price.  :)  http://SupersetSolutions.com/

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Pawel Jakub Dawidek
In reply to this post by Stefan Esser-3
On Mon, Jan 09, 2012 at 10:40:30AM +0100, Stefan Esser wrote:

> Am 09.01.2012 00:12, schrieb Doug Barton:
> > Attached is a patch that does what I suggested a long time ago, removes
> > set_rcvar() entirely and assigns each rcvar statically. I'll commit this
> > in a few days if no one objects. (Note, it can't be committed yet
> > because the scripts in ports that call set_rcvar() have to be modified
> > first.)
> [...]
> > Index: rc.d/nscd
> > ===================================================================
> > --- rc.d/nscd (revision 229825)
> > +++ rc.d/nscd (working copy)
> > @@ -19,7 +19,7 @@
> >  . /etc/rc.subr
> >
> >  name="nscd"
> > -rcvar=`set_rcvar`
> > +rcvar="nscd_enable"
>
> Why not generally use
>
> rcvar="${name}_enable"
>
> instead of (e.g.)
>
> rcvar="nscd_enable"
>
> in all scripts *in your patch set*, for which the outcome is the same?
I fully agree. There is one less thing to change after reusing a script.
I can't see how this might be a bad idea, really.

--
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

dougb
On 01/09/2012 02:21, Pawel Jakub Dawidek wrote:

> On Mon, Jan 09, 2012 at 10:40:30AM +0100, Stefan Esser wrote:
>> Am 09.01.2012 00:12, schrieb Doug Barton:
>>> Attached is a patch that does what I suggested a long time ago, removes
>>> set_rcvar() entirely and assigns each rcvar statically. I'll commit this
>>> in a few days if no one objects. (Note, it can't be committed yet
>>> because the scripts in ports that call set_rcvar() have to be modified
>>> first.)
>> [...]
>>> Index: rc.d/nscd
>>> ===================================================================
>>> --- rc.d/nscd (revision 229825)
>>> +++ rc.d/nscd (working copy)
>>> @@ -19,7 +19,7 @@
>>>  . /etc/rc.subr
>>>
>>>  name="nscd"
>>> -rcvar=`set_rcvar`
>>> +rcvar="nscd_enable"
>>
>> Why not generally use
>>
>> rcvar="${name}_enable"
>>
>> instead of (e.g.)
>>
>> rcvar="nscd_enable"
>>
>> in all scripts *in your patch set*, for which the outcome is the same?
>
> I fully agree. There is one less thing to change after reusing a script.
> I can't see how this might be a bad idea, really.

See my previous response.

If you still need help with that "search and replace" thing I can walk
you through it in vi. If you're an emacs user, you're on your own
though, sorry. :)


Doug

--

        You can observe a lot just by watching. -- Yogi Berra

        Breadth of IT experience, and depth of knowledge in the DNS.
        Yours for the right price.  :)  http://SupersetSolutions.com/

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Hiroki Sato
In reply to this post by dougb
Doug Barton <[hidden email]> wrote
  in <[hidden email]>:

do> On 01/07/2012 15:12, Hiroki Sato wrote:
do> >  I am always wondering if defining $rcvar as "${name}_enable" at the
do> >  end of load_rc_config() when $rcvar is undefined is bad idea.
do> >
do> >  Is there any problem with removing rcvar=... in individual rc.d
do> >  scripts except for non-standard ones (empty or different from
do> >  ${name}_enable)?  It looks simpler than writing the same line
do> >  "rcvar=${name}_enable" many times in various places.
do>
do> This sounds like a great idea in theory, but in practice it doesn't work
do> out, for 2 reasons. First, we have a lot of scripts in the base (about
do> 1/3) that rely on the lack of any rcvar meaning that it gets run
do> unconditionally. In order to provide backwards compatibility we'd have
do> to add code to enable things by default that were previously unset.
do> That's not hard to do, but ....
do>
do> The other reason is that for ports, the scripts generally look like this:
do>
do> load_rc_config foo
do>
do> : ${foo_enable:=NO}
do>
do> See the problem?

 Removing rcvar=`set_rcvar`, and then adding rcvar="" into scripts
 that need to be run unconditionally would work.  However, I have no
 strong opinion about that.  I agree that it needs some more code
 anyway and keeping things simple is better.

Doug Barton <[hidden email]> wrote
  in <[hidden email]>:

do> > The use of "${name}_enable" does not add measurable overhead, but that
do> > way more of an existing script might be used as a prototype unchanged.
do>
do> I understand what you're saying, and I know that the whole "use
do> variables wherever we can" thing is all '1337 and computer science'y,
do> but it's silly. The concept of a universal template that can be copied
do> and pasted for different services is a pipe dream. There are already
do> many things that need to be changed in the new script, and not updating
do> rcvar for a new script causes clear and obvious failure messages.

 I prefer to use ${name}_enable because putting the same keyword in
 two places always leads to a stupid typo issue.

-- Hiroki

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Pawel Jakub Dawidek
In reply to this post by dougb
On Mon, Jan 09, 2012 at 02:26:07AM -0800, Doug Barton wrote:

> On 01/09/2012 02:21, Pawel Jakub Dawidek wrote:
> > On Mon, Jan 09, 2012 at 10:40:30AM +0100, Stefan Esser wrote:
> >> Am 09.01.2012 00:12, schrieb Doug Barton:
> >>> Attached is a patch that does what I suggested a long time ago, removes
> >>> set_rcvar() entirely and assigns each rcvar statically. I'll commit this
> >>> in a few days if no one objects. (Note, it can't be committed yet
> >>> because the scripts in ports that call set_rcvar() have to be modified
> >>> first.)
> >> [...]
> >>> Index: rc.d/nscd
> >>> ===================================================================
> >>> --- rc.d/nscd (revision 229825)
> >>> +++ rc.d/nscd (working copy)
> >>> @@ -19,7 +19,7 @@
> >>>  . /etc/rc.subr
> >>>
> >>>  name="nscd"
> >>> -rcvar=`set_rcvar`
> >>> +rcvar="nscd_enable"
> >>
> >> Why not generally use
> >>
> >> rcvar="${name}_enable"
> >>
> >> instead of (e.g.)
> >>
> >> rcvar="nscd_enable"
> >>
> >> in all scripts *in your patch set*, for which the outcome is the same?
> >
> > I fully agree. There is one less thing to change after reusing a script.
> > I can't see how this might be a bad idea, really.
>
> See my previous response.
I saw your e-mail before agreeing with Stefan's proposal. And let me
repeat myself: I can't see how this might be a bad idea. Do you?

--
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Garrett Cooper
In reply to this post by Hiroki Sato
On Jan 9, 2012, at 5:35 AM, Hiroki Sato <[hidden email]> wrote:

> Doug Barton <[hidden email]> wrote
>  in <[hidden email]>:
>
> do> On 01/07/2012 15:12, Hiroki Sato wrote:
> do> >  I am always wondering if defining $rcvar as "${name}_enable" at the
> do> >  end of load_rc_config() when $rcvar is undefined is bad idea.
> do> >
> do> >  Is there any problem with removing rcvar=... in individual rc.d
> do> >  scripts except for non-standard ones (empty or different from
> do> >  ${name}_enable)?  It looks simpler than writing the same line
> do> >  "rcvar=${name}_enable" many times in various places.
> do>
> do> This sounds like a great idea in theory, but in practice it doesn't work
> do> out, for 2 reasons. First, we have a lot of scripts in the base (about
> do> 1/3) that rely on the lack of any rcvar meaning that it gets run
> do> unconditionally. In order to provide backwards compatibility we'd have
> do> to add code to enable things by default that were previously unset.
> do> That's not hard to do, but ....
> do>
> do> The other reason is that for ports, the scripts generally look like this:
> do>
> do> load_rc_config foo
> do>
> do> : ${foo_enable:=NO}
> do>
> do> See the problem?
>
> Removing rcvar=`set_rcvar`, and then adding rcvar="" into scripts
> that need to be run unconditionally would work.  However, I have no
> strong opinion about that.  I agree that it needs some more code
> anyway and keeping things simple is better.
>
> Doug Barton <[hidden email]> wrote
>  in <[hidden email]>:
>
> do> > The use of "${name}_enable" does not add measurable overhead, but that
> do> > way more of an existing script might be used as a prototype unchanged.
> do>
> do> I understand what you're saying, and I know that the whole "use
> do> variables wherever we can" thing is all '1337 and computer science'y,
> do> but it's silly. The concept of a universal template that can be copied
> do> and pasted for different services is a pipe dream. There are already
> do> many things that need to be changed in the new script, and not updating
> do> rcvar for a new script causes clear and obvious failure messages.
>
> I prefer to use ${name}_enable because putting the same keyword in
> two places always leads to a stupid typo issue.

+1
Thanks,
-Garrett_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Making use of set_rcvar.

Teske, Devin


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> On Behalf Of Garrett Cooper
> Sent: Monday, January 09, 2012 8:18 AM
> To: Hiroki Sato
> Cc: [hidden email]; [hidden email]
> Subject: Re: Making use of set_rcvar.
>
> On Jan 9, 2012, at 5:35 AM, Hiroki Sato <[hidden email]> wrote:
>
> > Doug Barton <[hidden email]> wrote
> >  in <[hidden email]>:
> >
> > do> On 01/07/2012 15:12, Hiroki Sato wrote:
> > do> >  I am always wondering if defining $rcvar as "${name}_enable" at
> > do> > the  end of load_rc_config() when $rcvar is undefined is bad idea.
> > do> >
> > do> >  Is there any problem with removing rcvar=... in individual rc.d
> > do> > scripts except for non-standard ones (empty or different from
> > do> > ${name}_enable)?  It looks simpler than writing the same line
> > do> > "rcvar=${name}_enable" many times in various places.
> > do>
> > do> This sounds like a great idea in theory, but in practice it
> > do> doesn't work out, for 2 reasons. First, we have a lot of scripts
> > do> in the base (about
> > do> 1/3) that rely on the lack of any rcvar meaning that it gets run
> > do> unconditionally. In order to provide backwards compatibility we'd
> > do> have to add code to enable things by default that were previously unset.
> > do> That's not hard to do, but ....
> > do>
> > do> The other reason is that for ports, the scripts generally look like
this:

> > do>
> > do> load_rc_config foo
> > do>
> > do> : ${foo_enable:=NO}
> > do>
> > do> See the problem?
> >
> > Removing rcvar=`set_rcvar`, and then adding rcvar="" into scripts that
> > need to be run unconditionally would work.  However, I have no strong
> > opinion about that.  I agree that it needs some more code anyway and
> > keeping things simple is better.
> >
> > Doug Barton <[hidden email]> wrote
> >  in <[hidden email]>:
> >
> > do> > The use of "${name}_enable" does not add measurable overhead,
> > do> > but that way more of an existing script might be used as a prototype
> unchanged.
> > do>
> > do> I understand what you're saying, and I know that the whole "use
> > do> variables wherever we can" thing is all '1337 and computer
> > do> science'y, but it's silly. The concept of a universal template
> > do> that can be copied and pasted for different services is a pipe
> > do> dream. There are already many things that need to be changed in
> > do> the new script, and not updating rcvar for a new script causes clear and
> obvious failure messages.
> >
> > I prefer to use ${name}_enable because putting the same keyword in two
> > places always leads to a stupid typo issue.
>
> +1
> Thanks,
> -Garrett

+1 again.
--
Devin

_____________
The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

dougb
In reply to this post by Hiroki Sato
On 01/09/2012 05:35, Hiroki Sato wrote:
>  I prefer to use ${name}_enable because putting the same keyword in
>  two places always leads to a stupid typo issue.

So, here's the thing. I understand what you're saying, I really do. The
problem is, you're still wrong. :)

There are MANY places where you have to use the value of $name literally
already, and typos count in every single one of them:

1. The name of the script file
2. PROVIDE
3. REQUIRE
4. names of service-specific methods, e.g.: start_precmd="foo_prestart"
5. Default values in /etc/defaults/rc.conf
6. rc.conf.5

And that's just off the top of my head. The ideal of being able to
copy/paste example rc.d scripts for use with new services without having
to change [m]any code sounds great in theory. In practice, search and
replace is an absolute necessity. So having one more place where you
have to replace the name of the old service with the new one isn't going
to hurt anything.

I haven't seen any objection to the _substance_ of my proposal, so I'm
going to go ahead with it tomorrow.


Doug

--

        You can observe a lot just by watching. -- Yogi Berra

        Breadth of IT experience, and depth of knowledge in the DNS.
        Yours for the right price.  :)  http://SupersetSolutions.com/

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Pawel Jakub Dawidek
On Fri, Jan 13, 2012 at 01:57:11AM -0800, Doug Barton wrote:

> On 01/09/2012 05:35, Hiroki Sato wrote:
> >  I prefer to use ${name}_enable because putting the same keyword in
> >  two places always leads to a stupid typo issue.
>
> So, here's the thing. I understand what you're saying, I really do. The
> problem is, you're still wrong. :)
>
> There are MANY places where you have to use the value of $name literally
> already, and typos count in every single one of them:
>
> 1. The name of the script file
> 2. PROVIDE
> 3. REQUIRE
> 4. names of service-specific methods, e.g.: start_precmd="foo_prestart"
> 5. Default values in /etc/defaults/rc.conf
> 6. rc.conf.5
>
> And that's just off the top of my head. The ideal of being able to
> copy/paste example rc.d scripts for use with new services without having
> to change [m]any code sounds great in theory. In practice, search and
> replace is an absolute necessity. So having one more place where you
> have to replace the name of the old service with the new one isn't going
> to hurt anything.
But if we can avoid it, why not? You gave no argument (valid one) why
using variables is wrose than hardcoding names everywhere.

> I haven't seen any objection to the _substance_ of my proposal, so I'm
> going to go ahead with it tomorrow.

Please don't. Touching so many rc.d files is PITA during mergemaster.
If we want to do that, let's do that once. The current consensus as I
see it, is that you are the only one wanting to hardcode names and there
are many in favour of using variables.

--
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Making use of set_rcvar.

Chris Rees-2
On 13 Jan 2012 14:12, "Pawel Jakub Dawidek" <[hidden email]> wrote:

>
> On Fri, Jan 13, 2012 at 01:57:11AM -0800, Doug Barton wrote:
> > On 01/09/2012 05:35, Hiroki Sato wrote:
> > >  I prefer to use ${name}_enable because putting the same keyword in
> > >  two places always leads to a stupid typo issue.
> >
> > So, here's the thing. I understand what you're saying, I really do. The
> > problem is, you're still wrong. :)
> >
> > There are MANY places where you have to use the value of $name literally
> > already, and typos count in every single one of them:
> >
> > 1. The name of the script file
> > 2. PROVIDE
> > 3. REQUIRE
> > 4. names of service-specific methods, e.g.: start_precmd="foo_prestart"
> > 5. Default values in /etc/defaults/rc.conf
> > 6. rc.conf.5
> >
> > And that's just off the top of my head. The ideal of being able to
> > copy/paste example rc.d scripts for use with new services without having
> > to change [m]any code sounds great in theory. In practice, search and
> > replace is an absolute necessity. So having one more place where you
> > have to replace the name of the old service with the new one isn't going
> > to hurt anything.
>
> But if we can avoid it, why not? You gave no argument (valid one) why
> using variables is wrose than hardcoding names everywhere.
>
> > I haven't seen any objection to the _substance_ of my proposal, so I'm
> > going to go ahead with it tomorrow.
>
> Please don't. Touching so many rc.d files is PITA during mergemaster.
> If we want to do that, let's do that once. The current consensus as I
> see it, is that you are the only one wanting to hardcode names and there
> are many in favour of using variables.
>

Well.... hardcoding IS faster.

Chris
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[hidden email]"
12
Loading...