From 70f6215c7d484bd6b80fe77065c8bc220f839ed9 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sun, 22 Jun 2025 15:57:12 +0100 Subject: [PATCH 1/2] build: fix install-data-hook for bash_completion.d It no longer matches bash_completion so it was not substituting for the actual compatdir due to a refactor. Follow-up for cdd8a157abdbb4ce2e74df3fd8131a2b199152e6 --- Makefile.am | 2 +- bash_completion | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 27366b7d9d3..849287645fe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,7 +36,7 @@ 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|($(compatdir)|' \ $(DESTDIR)$(datadir)/$(PACKAGE)/bash_completion >$$tmpfile && \ cat $$tmpfile >$(DESTDIR)$(datadir)/$(PACKAGE)/bash_completion && \ rm $$tmpfile diff --git a/bash_completion b/bash_completion index 12172ab3a29..45cf28fac38 100644 --- a/bash_completion +++ b/bash_completion @@ -3424,6 +3424,7 @@ _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+=(/etc/bash_completion.d) # Similarly as for the "completions" dir, look up from relative to # bash_completion, primarily for installed-with-prefix and From 9624bcb8ad8a388366351852b37fce25ef7954ea Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sun, 22 Jun 2025 16:02:52 +0100 Subject: [PATCH 2/2] 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. --- Makefile.am | 5 +++-- bash_completion | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 849287645fe..72dfa128541 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 @@ -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 diff --git a/bash_completion b/bash_completion index 45cf28fac38..48b3f4fb377 100644 --- a/bash_completion +++ b/bash_completion @@ -3425,6 +3425,7 @@ _comp__init_collect_startup_configs() 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 @@ -3436,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