Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Dec 2006 10:02:48 +0300
From:      Yar Tikhiy <yar@comp.chem.msu.su>
To:        Doug Barton <dougb@FreeBSD.org>
Cc:        freebsd-rc@FreeBSD.org
Subject:   Re: rc.d namespace
Message-ID:  <20061228070248.GC21493@comp.chem.msu.su>
In-Reply-To: <45930850.4070906@FreeBSD.org>
References:  <20061227105630.GB21493@comp.chem.msu.su> <45930850.4070906@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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
/etc/rc.d.

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.

-- 
Yar



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061228070248.GC21493>