[Bash-completion-devel] Namespace

Ville Skyttä ville.skytta at iki.fi
Mon May 9 22:14:43 UTC 2011

On 05/09/2011 01:03 AM, Freddy Vulto wrote:
> +1 for BASHCOMP_* for the setting variables (maybe we can also support a
> '.bashcomprc' file to allow a user to get rid of the globals)?

We already support ~/.bash_completion, wouldn't it work for that
purpose?  But I'm not entirely sure what you mean by getting rid of the
globals - do you mean that the .bashcomprc would always be sourced on
demand during every execution of the completion functions that need
something from it?

> _git_foo:   for completing `git foo'
> __git_foo:  for public/private functions

The thing I don't like about that is that they look a bit too similar
for my taste.  But that's not a major complaint, I could live with it.

> Maybe we'd better use __BC_ (two underscores
> and uppercase) for private library functions as well so that __bc_ is
> also free for completion writers (what are the chances of acroread
> creating a _bc_filedir or __bc_filedir where they ideally should use
> _bc_acroread_filedir?).

Hm, by "__bc_ is also free for completion writers" do you mean that it'd
be fine with us if 3rd party completion writers would define functions
starting with __bc_?  I'm not sure why that'd be desirable - it'd be
easy to confuse where a function originates then.  I think it'd be
clearer if we'd document that all function names starting with
BASHCOMP_, _+bc_, and _+BC_ (where "_+" means "one or more underscore")
as reserved to us in the sense that nobody else should define functions
or variables with those prefixes.

For the acroread case above, my thinking is that they can define
whatever they like as long as it doesn't match with what we define as
reserved.  So I don't think it'd be ok for them to define
_bc_acroread_filedir (but it'd be ok if that particular completion would
be included with bash-completion).  They should IMO use a prefix like
_acroread_* or _adobe_* instead, but as long as whatever they use
doesn't interfere with our reserved stuff, I don't really care ;)

> Summary:
> Completion functions: _bc_*
> Helper functions for specific completion (foo): _bc_foo_*
> Public API functions: _BC_*
> Private functions and private non-local variables: __BC_*

Works for me, but I think lowercase __bc_* is better for the last one in
order to not inflict a dual "sometimes public, sometimes private"
meaning to the uppercase BC things.

Also, _bc_foo_* also for non-local variables for a specific completion
in addition to helper functions for that specific completion?

More information about the Bash-completion-devel mailing list