Re: [PATCH] meson: install shell completion scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/9/25 1:42 PM, Junio C Hamano wrote:
> Todd Zullinger <tmz@xxxxxxxxx> writes:
> 
>>> Most people won't run into this since if you have this installed in the
>>> standard locations, it should just work, and the zsh script does have
>>> logic to look for additional paths it may be under. I just wanted to
>>> mention it for info.
>>
>> I wonder whether it is proper to install the completion
>> scripts relative to git's $datadir by default.
>>
>> I think the default ought to use the pkg-config call to get
>> the completionsdir variable, as the zsh completion script
>> suggests.  I am presuming that's something meson can do
>> rather trivially, just as it would do to find the compile
>> options for git's various build dependencies?
>>
>> I don't know if that becomes too messy to be worthwhile when
>> determining whether git is being installed by a normal user
>> in $HOME or by a privileged user in a system-wide prefix
>> like /usr.
> 
> Yes, exactly.  We left it out of what Makefile does for that exact
> reason.  Distros will do what is best for their environment, and I
> do not think, unlike pkg-config used to figure out distro specific
> locations when doing a system-wide install, there is a location that
> will make everybody happy in the context of per-user installation.
> 
> If we were to install these completion script from make or meson, I
> suspect that we'd eventually need a separate make variable or meson
> configuration item (whose default value can come from $datadir
> unless there is a better setting that already exists in our system)
> that is only used to specify the location completion script.


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:

- $XDG_DATA_HOME defaulting to ~/.local/share
- entries in $PATH / the dirname for the absolute path to the completed
  program, if they match */bin/ or */sbin/ will calculate an additional
  datadir value of */share/
- $XDG_DATA_DIRS as a :-list defaulting to /usr/local/share:/usr/share


This is very difficult to get wrong, you are virtually guaranteed to get
essentially any conceivable layout handled. Entry #2 on my list is
pretty much the ultimate recourse, 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

With zsh, things are a lot shakier. Canonically, there is a designated
loader list for all zsh functions, including completions, and that is
$fpath. It doesn't attempt to do anything fancy like indexing into $PATH.

The default zsh ./configure settings will add these two directories, and
nothing else:

/usr/local/share/zsh/site-functions
/usr/share/zsh/site-functions


So, it works if and only if you build software using a prefix of /usr or
else /usr/local, and if you install software in $HOME then you are ummmm
encouraged to have your ~/.zshrc manually add some directory of your
arbitrary choosing.

Oh, and it also doesn't work on Debian, because of
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=934926

(I'm aware of this bug because when Joey Hess said "The simple fact is
that as an upstream author who used the debian locations because they
were the ones that worked on my system, I get bug reports from users of
other systems that it's not right for wider uses of zsh." -- I was the
user who caused him to file that bug in the first place.)

tl;dr on Debian, the directories which you are allowed to use are

/usr/local/share/zsh/site-functions
/usr/share/zsh/vendor-functions
/usr/share/zsh/vendor-completions


with the intention that you use the third one. They seem adamant that
"vendor-completions" is such a better name than "site-functions" that
they will require all debian packages to manually move their completions
from the latter to the former, probably after running "meson install"...



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.


-- 
Eli Schwartz

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux