Skip to content

Commit 966a4e0

Browse files
akinomyogascop
andcommitted
fix(bash_completion): support BASH_COMPLETION_COMPAT_IGNORE
We remove the workaround for the "acroread.sh" and instead expose a customization point via the new shell variable "BASH_COMPLETION_COMPAT_IGNORE" so that the user can specify the files in "BASH_COMPLETION_COMPAT_DIR" to ignore. Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
1 parent 3414cb6 commit 966a4e0

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

bash_completion

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ else
3737
set +v
3838
fi
3939

40-
# Blacklisted completions, causing problems with our code.
41-
#
42-
_comp__init_blacklist_glob='@(acroread.sh)'
43-
4440
# Turn on extended globbing and programmable completion
4541
shopt -s extglob progcomp
4642

@@ -2519,11 +2515,11 @@ _comp_deprecate_func _xfunc _comp_xfunc
25192515
_comp__init_compat_dir=${BASH_COMPLETION_COMPAT_DIR:-/etc/bash_completion.d}
25202516
if [[ -d $_comp__init_compat_dir && -r $_comp__init_compat_dir && -x $_comp__init_compat_dir ]]; then
25212517
for _comp__init_file in "$_comp__init_compat_dir"/*; do
2522-
[[ ${_comp__init_file##*/} != @($_comp_backup_glob|Makefile*|$_comp__init_blacklist_glob) &&
2518+
[[ ${_comp__init_file##*/} != @($_comp_backup_glob|Makefile*|${BASH_COMPLETION_COMPAT_IGNORE-}) &&
25232519
-f $_comp__init_file && -r $_comp__init_file ]] && . "$_comp__init_file"
25242520
done
25252521
fi
2526-
unset -v _comp__init_compat_dir _comp__init_file _comp__init_blacklist_glob
2522+
unset -v _comp__init_compat_dir _comp__init_file
25272523
25282524
# source user completion file
25292525
#

doc/configuration.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,32 @@ known hosts completion will omit hostnames from `HOSTFILE`. Omitting
4646
hostnames from `HOSTFILE` is useful if `HOSTFILE` contains many entries for
4747
local web development or ad-blocking.
4848

49+
### `BASH_COMPLETION_COMPAT_IGNORE`
50+
51+
Files in `BASH_COMPLETION_COMPAT_DIR` (the compat dir) to ignore, specified by
52+
a glob pattern. The completion files in the compat dir whose basename matches
53+
with this pattern will not be sourced by `bash_completion` at its load time.
54+
This variable can be used to suppress the problematic completions. Note that
55+
backup files and Makefiles in the compat dir are by default ignored regardless
56+
of this setting.
57+
58+
One example is `acroread.sh` which is installed by some versions of Adobe
59+
Reader, overrides `_filedir` with an incompatible version, and causes
60+
various problems. To recover this `_filedir`, another completion file
61+
`redefine_filedir` had been placed in the compat dir, which could also
62+
cause another incompatibility when the user uses their own version of
63+
bash-completion instead of the systemwide version. To suppress these files
64+
one can set the following value:
65+
66+
```bash
67+
export BASH_COMPLETION_COMPAT_IGNORE='@(acroread.sh|redefine_filedir)'
68+
```
69+
70+
- <https://bugzilla.redhat.com/677446>
71+
- <http://forums.adobe.com/thread/745833>
72+
- <https://bugzilla.redhat.com/show_bug.cgi?id=1171396#c27>
73+
- <https://github.com/scop/bash-completion/pull/667>
74+
4975
### `BASH_COMPLETION_CMD_CONFIGURE_HINTS`
5076

5177
If set and not null, `configure` completion will return the entire option

test/config/bashrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export BASH_COMPLETION_USER_DIR=$(
4141
)
4242
# /var/empty isn't necessarily actually always empty :P
4343
export BASH_COMPLETION_COMPAT_DIR=/var/empty/bash_completion.d
44+
export BASH_COMPLETION_COMPAT_IGNORE='*'
4445
export XDG_DATA_DIRS=/var/empty
4546

4647
# Make sure default settings are in effect

0 commit comments

Comments
 (0)