bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BASH_FUNC__ appearing in environment


From: Geir Hauge
Subject: Re: BASH_FUNC__ appearing in environment
Date: Fri, 28 Nov 2014 10:02:47 +0100



2014-11-28 9:43 GMT+01:00 steveT <stevetucknott@yahoo.co.uk>:
OK - found the functions that are appearing. I was grepping BASH_FUNC__ in etc - wrong. The functions are in the /usr/share/bash-completion/completions directory - and exist as rcs and sudo  files. The code in those files defines functions for _rcs and _sudo respectively. The rcs file contains:

# bash completion for rcs                                  -*- shell-script -*-

_rcs()
{
 [--snipp--]
} &&
complete -F _rcs ci co rlog rcs rcsdiff

# ex: ts=4 sw=4 et filetype=sh

OK - so that is the code that appears in my environment as BASH_FUNC__rcs - now the question is - why - and why does it persist? I am not aware of using completion with sudo or rcs - so where/why/how in bash do these /usr/share scripts get actioned?

The third-party bash-completion package sets a "default completion function" (see it with complete -p -D; declare -f _completion_loader) that dynamically loads completions. For instance, if you do

$ rcs TAB

And there is not already a completion loaded for rcs, It will look for /usr/share/bash-completion/completions/rcs, source it if it finds it, then use the new completion. This in itself will not cause the function to be exported. I can only think of two ways of the function being exported, and that's by

1. specifically exporting it with ''export -f _rcs'' or ''declare -xf _rcs''
2. you happen to run ''set -a'' at some point before the completion function gets dynamically loaded. When ''set -a'' is in effect, all variables and functions you define get automatically exported. If the output of ''echo "$-"'' contains 'a', then it is in effect.

--
Geir Hauge

reply via email to

[Prev in Thread] Current Thread [Next in Thread]