Subject: Re: meson: Installing completions

From: Patrick Steinhardt <[email-masked]>
Date: Wed, 2 Apr 2025 13:33:59 +0200

On Tue, Apr 01, 2025 at 08:58:38PM -0400, Todd Zullinger wrote:
> Akshay Hegde wrote:
> > On 2025-04-01 11:58 +0200, Patrick Steinhardt wrote:
> >>The biggest question though is whether distros are aligned enough for us
> >>to provide standard installation paths. That is, do all distros end up
> >>installing bash completion into "/usr/share/bash-completion"? What are
> >>the desired directories for tcsh and zsh completion?
> >>
> >>If there is enough standardization then yes, I totally think we should
> >>start installing completion scripts automatically.
> > 
> > Well I can't speak from any sort of authoritativeness here, but for zsh,
> > they are usually installed underneath the datadir (usually /usr/share),
> > then under zsh/site-functions. Of course, I don't know if that's true
> > for all distros.
> > 
> > Could we extend meson_options to allow specification of bash/tcsh/zsh
> > completion directories? If they are not empty, I think it would be
> > reasonable to have meson install it automatically.
> 
> Having the ability to specify the install path seems like
> the way to go, even if the default is used by most systems.
> For Fedora, only the bash and tcsh completions are
> installed.  The latter is simply placed in:
> 
>     /usr/share/git-core/contrib/completion/git-completion.tcsh
> 
> and users need to make some adjustments to their startup
> scripts to use it, as documented in the file.  This was
> added to the Fedora packages in:
> 
>     commit dae8588
>     Author: Todd Zullinger <[email-masked]>
>     Date:   Thu Jan 3 14:59:27 2013 -0500
> 
>         For now, this just gets the file from contrib installed.  If there are
>         enough tcsh users that want it to be more automated, that can come
>         later.  For now, the directions in the file must be followed to enable
>         tcsh completion.
> 
> In the years I maintained git in Fedora, no one asked for
> any changes for tcsh.  Apparently, either no one uses that
> or they don't mind the manual work to configure it. :)

One of the questions is whether we gain a lot by making this an option.
If packagers have to manually adapt the location they could just as well
copy the file by hand as there is no build step involved in the first
place. I also think that for Bash and zsh the locations are somewhat
stable across distros these days, so ideally we could just build on that
and not even provide an option in the first place?

I'm mostly trying to avoid to eventually end up with tons of build
options. Ideally, we should just do the right thing and install the
completion scripts into the correct location in the specified prefix.

At least if we can get away with it. It seems like the default location
would work alright for you on Fedora, and I assume that it would work
alright for most of the other distros. So I'd refrain from introducing
an option now, but if we eventually figure out that this is problematic
on some distro then we can still introduce the option at a later point
in time.

> IIRC, there are git completions installed by upstream zsh
> and installing git-completion.zsh site-wide is not generally
> agreed that everyone wants?  I'm not a zsh user, but I think
> that's why I never installed it in the Fedora git packaging.
> (It does seem like an oversight that they aren't at least
> installed similarly to the tcsh completion.)
> 
> For reference, here are the locations for bash, fish, and
> zsh which Fedora uses.  This might be helpful in determining
> reasonable defaults (after comparing to other distributions,
> of course):
> 
>     bash /usr/share/bash-completion/completions
>     fish /usr/share/fish/vendor_completions.d
>     zsh  /usr/share/zsh/site-functions

We don't have completions for the Fish shell, right? Just making sure
that I don't miss the obvious.

Patrick