yar at comp.chem.msu.su
Wed Dec 27 23:02:54 PST 2006
On Wed, Dec 27, 2006 at 03:57:04PM -0800, Doug Barton wrote:
> Yar Tikhiy wrote:
> > Hi folks,
> > My attention has been drawn by the fact that rc.subr and rc.d/*
> > don't seem to follow uniform namespace rules.
> In general I'm in favor of consistency, but could you be more specific
> about what problem you're trying to solve?
"Don't fix a working thing", huh? :-)
The problem is that clashes are possible between global names in
rc.subr itself and those in rc.d scripts unless we separate their
namespaces. The current situation isn't quite tangled yet, so it
is good time to take care of the future.
> > Namely both rc.subr
> > and rc.d use global identifiers starting with an underscore.
> > Fortunately, rc.subr doesn't seem to use global identifiers not
> > starting with an underscore besides the names exported to scripts
> > on purpose.
> That's good news.
> > What do you think about adopting the following rule: "_foo" names
> > are for the rc.subr internals while just "foo" names are for rc.d
> > scripts?
> That works for me, especially if we don't have to make a lot of
> gratuitous changes to rc.subr. I would like to minimize the pain of
> adopting any new stuff from NetBSD if possible.
Thanks. In this way, only some rc.d scripts have to be changed.
> > Another possible way is: __foo or even __rc_foo for
> > rc.subr, _foo for scripts, foo for the documented rc.subr interface.
> Personally I think that's too much drama. Since they are executed in a
> subshell, I don't really see a need for variables in individual rc.d
> scripts to be so careful about their namespace that they need
> something like _foo to start with, so I'd rather "enforce" this for
> the scripts than make radical changes to rc.d itself.
It's true that different rc.d scripts run in different subshells,
but each script shares its actual namespace with rc.subr, which can
need private (i.e., undocumanted in rc.subr(8)) global objects such
as variables and functions. That's why I suggest lexically separating
the namespace of rc.subr and that of end-consumer scripts living in
For now, in order to avoid a name collision, an rc.d developer has
to grep all scripts in /etc/rc.d (and potentially in /usr/local/etc/rc.d)
when he wants to add a global var or func to /etc/rc.sbur; and he
has to grep /etc/rc.subr when he is about to add to /etc/rc.d a new
script using global names.
More information about the freebsd-rc