Conventions for variables names in rc.d scripts

Doug Barton dougb at FreeBSD.org
Thu Jun 1 10:41:58 PDT 2006


Florent Thoumie wrote:
> I'd like to make the following changes in rc.d scripts.
> 
> - Make all script-local all variable names begin with the "_${name}_"
> prefix.

Sounds like a good plan.

> - Make all functions-local variable names begin with the "_" prefix and
> use the "local" keyword.

Not as confident about this one, for two reasons. One I think it's overkill,
and two I'd be worried that some script might actually expect to get a local
copy of the named variable. However, if it gets enough testing, my objection
is not strong enough to say "don't do it."

> This would avoid potential collision with rc.conf variables and other
> variables defined in rc.subr or network.subr that aren't declared local.
> 
> Later I'd like to use the "local" keyword as much as possible in rc.subr
> and network.subr.

We should be doing this anyway. In fact, I would suggest that you introduce
this first, then wait a week or two to start frobbing the scripts themselves
to help isolate the cause of any breakage.

> Are there strong objections against these changes?
> 
> On a different matter, I've noticed that some of our scripts have
> "#!/bin/sh -" shebang line instead of "#!/bin/sh" and just couldn't find
> a good reason for this. Anybody knows why?

Most likely because they were imported from NetBSD that way. I'd say remove
it and test thoroughly. :)

Doug

-- 

    This .signature sanitized for your protection



More information about the freebsd-rc mailing list