[Bash-completion-devel] [Bash-completion-commits] [SCM] bash-completion branch, master, updated. 7d45595493e1f830a3ddbdff845f05ce5a0bc696

Ville Skyttä ville.skytta at iki.fi
Mon Nov 8 07:27:04 UTC 2010


On Monday 08 November 2010, Ville Skyttä wrote:
> On Sunday 07 November 2010, Guillaume Rousse wrote:
> > Unfortunatly, I also realized than as long as we don't have a
> > standardized configuration process, we can't do it easily. Unless we use
> > an ugly mix of 'enable-if-defined' and 'disable-if-defined' environment
> > variables :/
> 
> I'm afraid we'll end up needing something like that eventually.

...but then again we can use the values of those variables and not just their 
names which takes most of the pain away (at the expense of being a backwards 
incompatible change), for example something like:

# $1=variable without COMP_ prefix
# $2=default value if unset
_comp_feature_enabled()
{
    eval "local value=\$COMP_$1"
    [[ ${value:-$2} == @([1TtYy]|[Oo][Nn])* ]]
}

# unset/empty defaults to off
if _comp_feature_enabled SOMETHING ; then
    echo "COMP_SOMETHING is on"
else
    echo "COMP_SOMETHING is off"
fi

# unset/empty defaults to on
if _comp_feature_enabled OTHERTHING on ; then
    echo "COMP_OTHERTHING is on"
else
    echo "COMP_OTHERTHING is off"
fi



More information about the Bash-completion-devel mailing list