Skip to content

Fix regression in install-data-hook, support sourcing bash_completion.d from /usr/share/ and move ours #1399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SUBDIRS = completions doc helpers test
pkgdata_DATA = bash_completion

# Empty, but here just to get the compat dir created with install
compatdir = $(sysconfdir)/bash_completion.d
compatdir = $(datadir)/bash-completion/compat
compat_DATA = bash_completion.d/000_bash_completion_compat.bash

profiledir = $(sysconfdir)/profile.d
Expand Down Expand Up @@ -36,7 +36,8 @@ EXTRA_DIST = CHANGELOG.md $(pkgdata_DATA) bash_completion.sh.in .dir-locals.el \

install-data-hook:
tmpfile=`mktemp $${TMPDIR:-/tmp}/bash_completion.XXXXXX` && \
$(SED) -e 's|-/etc/bash_completion\.d|-$(compatdir)|' \
$(SED) -e 's|(/etc/bash_completion\.d|($(sysconfdir)/bash_completion.d|' \
-e 's|(/usr/share/bash-completion/compat|($(compatdir)|' \
$(DESTDIR)$(datadir)/$(PACKAGE)/bash_completion >$$tmpfile && \
cat $$tmpfile >$(DESTDIR)$(datadir)/$(PACKAGE)/bash_completion && \
rm $$tmpfile
11 changes: 10 additions & 1 deletion bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -3424,6 +3424,8 @@ _comp__init_collect_startup_configs()
if [[ ${BASH_COMPLETION_COMPAT_DIR-} ]]; then
compat_dirs+=("$BASH_COMPLETION_COMPAT_DIR")
else
# Keep in sync with install-data-hook at Makefile.am
compat_dirs+=(/usr/share/bash-completion/compat)
compat_dirs+=(/etc/bash_completion.d)
# Similarly as for the "completions" dir, look up from relative to
# bash_completion, primarily for installed-with-prefix and
Expand All @@ -3435,7 +3437,14 @@ _comp__init_collect_startup_configs()
else
compat_dir=$_comp__base_directory/bash_completion.d
fi
[[ ${compat_dirs[0]} == "$compat_dir" ]] ||
local dir
for dir in "${compat_dirs[@]}"; do
if [[ $dir == "$compat_dir" ]]; then
compat_dir=""
break
fi
done
[[ $compat_dir ]] &&
compat_dirs+=("$compat_dir")
fi
for compat_dir in "${compat_dirs[@]}"; do
Expand Down