[bug#77181,0/5] gnu: Fix bash completion directories.

Message ID cover.1742655515.git.45mg.writes@gmail.com
Headers
Series gnu: Fix bash completion directories. |

Message

45mg March 22, 2025, 3:04 p.m. UTC
  The following patches correct the exact same mistake found in 5 package
definitions: bash completions were installed to '/etc/bash-completion.d'
instead of '/etc/bash_completion.d'. The latter is necessary for the
bash-completion package to find and load the installed completions.

45mg (5):
  gnu: pass-age: Fix bash completion directory.
  gnu: ouch: Fix bash completion directory.
  gnu: git-delta: Fix bash completion directory.
  gnu: zoxide: Fix bash completion directory.
  gnu: starship: Fix bash completion directory.

 gnu/packages/password-utils.scm | 2 +-
 gnu/packages/rust-apps.scm      | 6 +++---
 gnu/packages/shellutils.scm     | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)


base-commit: fbfd2b93831978aadbb96f32cafdab997b04c6c6
  

Comments

Ian Eure March 22, 2025, 4:37 p.m. UTC | #1
Hi 45mg,

45mg <45mg.writes@gmail.com> writes:

> The following patches correct the exact same mistake found in 5 
> package
> definitions: bash completions were installed to 
> '/etc/bash-completion.d'
> instead of '/etc/bash_completion.d'. The latter is necessary for 
> the
> bash-completion package to find and load the installed 
> completions.
>

The changes seem fine, but could you link to somewhere explaining 
(or explain yourself) how bash completions are supposed to work? 
In addition to /etc/bash_completions.d, I see many packages 
installing them into /share/bash-completion.  Do both locations 
work?  Do we need to move eveything into one or the other 
location?

Thanks,

  -- Ian
  
45mg March 22, 2025, 5:22 p.m. UTC | #2
Hi Ian,

Ian Eure <ian@retrospec.tv> writes:

[...]
> The changes seem fine, but could you link to somewhere explaining 
> (or explain yourself) how bash completions are supposed to work? 
> In addition to /etc/bash_completions.d, I see many packages 
> installing them into /share/bash-completion.  Do both locations 
> work?  Do we need to move eveything into one or the other 
> location?

Here's a snippet from the bash-completion project's FAQ, explaining
this:
https://github.com/scop/bash-completion?tab=readme-ov-file#faq

--8<---------------cut here---------------start------------->8---
Q. I author/maintain package X and would like to maintain my own
completion code for this package. Where should I put it to be sure that
interactive bash shells will find it and source it?

A. [ Disclaimer: Here, how to make the completion code visible to
bash-completion is explained. We do not require always making the
completion code visible to bash-completion. In what condition the
completion code is installed should be determined at the
author/maintainers' own discretion. ]

Install it in one of the directories pointed to by bash-completion's
pkgconfig file variables. There are two alternatives:

    The recommended directory is completionsdir, which you can get with
    pkg-config --variable=completionsdir bash-completion. From this
    directory, completions are automatically loaded on demand based on
    invoked commands' names, so be sure to name your completion file
    accordingly, and to include (for example) symbolic links in case the
    file provides completions for more than one command. The completion
    filename for command foo in this directory should be either foo, or
    foo.bash. (Underscore prefixed _foo works too, but is reserved for
    bash-completion internal use as a deprecation/fallback marker.)
    
    The other directory which is only present for backwards
    compatibility, its usage is no longer recommended, is compatdir (get
    it with pkg-config --variable=compatdir bash-completion). From this
    directory, files are loaded eagerly when bash_completion is loaded.
--8<---------------cut here---------------end--------------->8---


On Guix, we have:

--8<---------------cut here---------------start------------->8---
# guix shell pkg-config bash-completion

[user@guix1 ]$ pkg-config --variable=completionsdir bash-completion
/gnu/store/5774mb64pqw93fpcchndiiq9fh80ngga-bash-completion-2.11/share/bash-completion/completions

[user@guix1 ]$ pkg-config --variable=compatdir bash-completion
/gnu/store/5774mb64pqw93fpcchndiiq9fh80ngga-bash-completion-2.11/etc/bash_completion.d
--8<---------------cut here---------------end--------------->8---

So, it looks like we should ideally be installing into
share/bash-completion/completions everywhere. etc/bash_completion.d will
also work, but the former is preferred because completions will be
loaded on-demand rather than eagerly. There are currently dozens of
packages using the latter; maybe some of them have a reason to
eager-load their completions.