Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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: – cayblood 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. – cayblood Apr 26 '12 at 14:10

You must log in to answer this question.

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