Skip to content

Commit e48fc69

Browse files
committed
feat: load compatdir from /usr/share too and install our script there
In distributions we are in the process of moving data shipped by upstream projects to /usr/ and out of /etc/, as the latter is really meant to be for local changes, not for upstream projects to ship programs/data. Add support for sourcing compat scripts from /usr/share/bash-completion/compat/ together with /etc/bash_completion.d, and move 000_bash_completion_compat.bash to the former.
1 parent 594de4e commit e48fc69

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Makefile.am

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ SUBDIRS = completions doc helpers test
22

33
pkgdata_DATA = bash_completion
44

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

98
profiledir = $(sysconfdir)/profile.d
@@ -34,9 +33,12 @@ EXTRA_DIST = CHANGELOG.md $(pkgdata_DATA) bash_completion.sh.in .dir-locals.el \
3433
bash-completion-config-version.cmake.in setup-symlinks.sh \
3534
$(compat_DATA)
3635

36+
# Create and install empty directory for local completion scripts in sysconfdir
3737
install-data-hook:
3838
tmpfile=`mktemp $${TMPDIR:-/tmp}/bash_completion.XXXXXX` && \
39-
$(SED) -e 's|(/etc/bash_completion\.d|($(compatdir)|' \
39+
$(SED) -e 's|(/etc/bash_completion\.d|($(sysconfdir)/bash_completion.d|' \
40+
-e 's|(/usr/share/bash-completion/compat|($(compatdir)|' \
4041
$(DESTDIR)$(datadir)/$(PACKAGE)/bash_completion >$$tmpfile && \
4142
cat $$tmpfile >$(DESTDIR)$(datadir)/$(PACKAGE)/bash_completion && \
4243
rm $$tmpfile
44+
$(MKDIR_P) $(DESTDIR)$(sysconfdir)/bash_completion.d

bash_completion

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3492,6 +3492,7 @@ _comp__init_collect_startup_configs()
34923492
compat_dirs+=("$BASH_COMPLETION_COMPAT_DIR")
34933493
else
34943494
# Keep in sync with Makefile.am install-data-hook
3495+
compat_dirs+=(/usr/share/bash-completion/compat)
34953496
compat_dirs+=(/etc/bash_completion.d)
34963497
# Similarly as for the "completions" dir, look up from relative to
34973498
# bash_completion, primarily for installed-with-prefix and
@@ -3503,7 +3504,14 @@ _comp__init_collect_startup_configs()
35033504
else
35043505
compat_dir=$_comp__base_directory/bash_completion.d
35053506
fi
3506-
[[ ${compat_dirs[0]} == "$compat_dir" ]] ||
3507+
local dir
3508+
for dir in "${compat_dirs[@]}"; do
3509+
if [[ $dir == "$compat_dir" ]]; then
3510+
compat_dir=""
3511+
break
3512+
fi
3513+
done
3514+
[[ $compat_dir ]] &&
35073515
compat_dirs+=("$compat_dir")
35083516
fi
35093517
for compat_dir in "${compat_dirs[@]}"; do

0 commit comments

Comments
 (0)