Subject: Re: [PATCH] meson: install shell completion scripts

From: Junio C Hamano <[email-masked]>
Date: Thu, 17 Apr 2025 07:31:55 -0700

Eli Schwartz <[email-masked]> writes:

> bash-completion looks for scripts in a few different places, with a
> common theme that there is a "datadir" followed by the literal path
> bash-completion/completions -- some values for the datadir:
> ...
> ... since as long as you leave meson
> datadir and bindir alone you can install into absolutely any prefix, no
> matter how weird, and successfully invoking `git` itself will as a side
> effect add the correct bash completion file.
>
> And that also means that distros automatically do the right thing --
> just configure with prefix=/usr and we get
> /usr/share/bash-completion/completions as expected

OK, so that is clear and easy.  Next to where we have

    infodir = $(prefix)/share/info

we add

    bash_completion_dir = $(prefix)/share/bash-completion/completions

and everybody would be happy.  We do the parallel on the meson side.

> With zsh, things are a lot shakier. ...
> ... (a lot of explanation on zsh installation path quirks omitted)
> So, my personal feelings on this patch are that we can and should
> unambiguously install the bash completion, but it would be reasonable to
> defer handling zsh until someone figures out how to do it correctly,
> which may be impossible.

Sounds good.  Or just use

    zsh_completion_dir = $(prefix)/share/zsh/site-functions

perhaps.  Those who are making personal installation under $HOME at
least would know that what they have under $prefix mirrors the
/usr/{bin,lib,share,....}/ if things were installed for host, so
even though zsh does not look into there, at least the layout would
be familiar to the user.  But I am even happier if we decide to
leave it out as you suggested.

Thanks.