bash-completion icon indicating copy to clipboard operation
bash-completion copied to clipboard

Conflicts with CLICOLOR_FORCE

Open defjaf opened this issue 9 years ago • 2 comments

(The following has to do with the version of bash-completion that ships with OS X homebrew; apologies if it's not relevant to current versions.)

Various aspects of the completion scripts conflict with CLICOLOR_FORCE, an environment variable which forces ls to output terminal colour codes even when not obviously running interactively (useful for piping through less, etc).

The most glaring issue is in the have() function, which fails so that none of the completions get set up, but this only needs to happen when the bash-completion script is run, so can be fixed by setting the variable later on in the startup. But some of the scripts (e.g., for ssh) seem to rely on ls to generate filename lists on-the-fly which means that they come out mangled. For example:

$ scp .bas<tab>
^[\[34m.bash_sessions^[\[39\;49m^[\[0m/
.bashrc 

(Minor update: I've realised that for my own use case, which is really limited to needing CLICOLOR_FORCE for only one command, I've just added CLICOLOR_FORCE=1 into the function defined for it, so I don't need it globally. But this is still a minor bug, I think...)

defjaf avatar May 25 '16 09:05 defjaf

This is the first time I've heard of CLICOLOR_FORCE and I don't have a system to test it with, but from what I understand I think enabling it globally is asking for trouble, and the proper way to use it is selectively where needed. I'm inclined to close this with the workaround being "just don't do it".

Current bash-completion still has the have() function but it's not really necessary any more nor used by bash-completion, it exists only for backwards compatibility. It's likely that the above issue still exists with current versions though. In any case, I suggest upgrading bash-completion to an up to date version before reporting issues here, it's extremely unlikely that any work on earlier versions than the current 2.x line will be done.

scop avatar May 25 '16 16:05 scop

I think this can also be closed. I agree that we shouldn't set the variable globally. That would break many shell scripts, and the issue is not specific to bash-completion.

I think a realistic usage for such a variable is to use it with an alias (alias ls='CLICOLOR_FORCE=1 ls'), a shell function (myls() { local -x CLICOLOR_FORCE=1; ls "$@"; }), or an executable script (#/usr/bin/env bash\nexport CLIPCOLOR_FORCE=1\nls "$@").

akinomyoga avatar May 13 '24 09:05 akinomyoga