Skip to content

Commit

Permalink
Make user completion file configurable, disable in tests
Browse files Browse the repository at this point in the history
No longer need to override $HOME with this. Doing that made some tilde
expansion tests fail, because the overridden value affected
eval-expansion of only plain ~, not ~user (for the same user).

Fixes #128
  • Loading branch information
scop committed Jul 1, 2017
1 parent 1a7137f commit d231255
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -2078,8 +2078,11 @@ fi
unset compat_dir i _blacklist_glob

# source user completion file
[[ ${BASH_SOURCE[0]} != ~/.bash_completion && -r ~/.bash_completion ]] \
&& . ~/.bash_completion
user_completion=${BASH_COMPLETION_USER_FILE:-~/.bash_completion}
[[ ${BASH_SOURCE[0]} != $user_completion && -r $user_completion ]] \
&& . $user_completion
unset user_completion

unset -f have
unset have

Expand Down
5 changes: 3 additions & 2 deletions doc/bash_completion.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ Bash completion
Configuration files
-------------------

*~/.bash_completion*::
*$BASH_COMPLETION_USER_FILE*::
Sourced late by bash_completion, pretty much after everything else.
Use this file for example to load additional completions, and to remove
and override ones installed by bash_completion.
and override ones installed by bash_completion. Defaults to
`~/.bash_completion` if unset or null.

*$XDG_CONFIG_HOME/bash_completion*::
Sourced by the bash_completion.sh profile.d script. This file is
Expand Down
2 changes: 1 addition & 1 deletion test/config/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
# ...as well as games on some systems not in PATH by default:
export PATH=$PATH:/usr/games:/usr/local/games
# For clean test state, avoid sourcing user's ~/.bash_completion
export HOME=$SRCDIR/config
export BASH_COMPLETION_USER_FILE=/dev/null
# ...and avoid stuff in BASH_COMPLETION_USER_DIR overriding in-tree
# completions. The user dir is first in the lookup path, so this should also
# give precedence to the in-tree "completions" dir over other ones, e.g.
Expand Down

0 comments on commit d231255

Please sign in to comment.