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

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.

1 Answer 1


$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.)

  • 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
    – cayblood
    Apr 24, 2012 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... Apr 24, 2012 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.
    – cayblood
    Apr 26, 2012 at 14:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .