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: steveT
Subject: Re: BASH_FUNC__ appearing in environment
Date: Fri, 28 Nov 2014 05:31:47 -0800 (PST)
User-agent: G2/1.0

On Friday, 28 November 2014 09:02:56 UTC, Geir Hauge  wrote:
> 2014-11-28 9:43 GMT+01:00 steveT <stevet...@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

Geir,
The set -a route must be it, as the echo shows -a being set and looking at the 
.bash_profile , it uses set -a. Also - when using 'set', I don't see the rcs or 
sudo completion being there, so presumably, at some point in my working day, 
the rcs/sudo completion is loaded and because of the set -a, then appears in my 
environment.


Thanks Geir and all for your help.


reply via email to

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