Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using homebrew's bash completion package on OSX, which is installed in /usr/local/etc/bash_completion. It's working fine, but there are many extensions for it which rely on various environment variables beginning with COMP_, such as COMP_LINE. These environment variables unfortunately aren't being exported into my bash environment, despite the fact that the proper files are being sourced. Here is the applicable area in my .bash_profile:

# bash completion
if [ -f `brew --prefix`/etc/bash_completion ]; then
  . `brew --prefix`/etc/bash_completion
  . /usr/local/etc/bash_completion.d/git-completion.bash
fi

Yet COMP_LINE isn't set, which is preventing other completion addons from working:

> env | grep COMP_LINE
>

Any ideas why the environment variables aren't set? Thanks in advance for your time.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

$COMP_LINE is not an environment variable. It is an internal variable, and it's only visible to the completion functions, not to other shell usage. (Most other internal variables are visible in declare.)

share|improve this answer
    
I guess I'm confused because this script seems to be expecting that variable to be available in the environment and is not finding it: github.com/xaviershay/dotfiles/blob/master/bin/rake-complete.rb –  Carl Youngblood Apr 24 '12 at 13:08
    
The script expects it, because it is normally invoked inside a completion handler (actually as a completion handler). I was wrong about the variable type, though -- it seems that COMP_* variables are being exported to the environment. I have tried the rake-complete script and it works... –  grawity Apr 24 '12 at 20:34
    
Thanks, it appears the completion script was actually working but there was a bug in it that was skipping the first rake task in the list, which just happened to be the one I was trying to execute. –  Carl Youngblood Apr 26 '12 at 14:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.