Bash completion support for ports

Hello!
I’m in the process of updating minipro (it’s a small program to control some IC programmers) to the last version and at the same time fix some mistakes I did in the first version (it’s my first recipe ahah).

One of them is the lack of bash completion support. Minipro has it’s own bash completion file in it’s source and I’m trying to make it work with Haiku.

I tried to put it in /packages/minipro-0.7-1/.self/data/bash-completion/completions/ but it doesn’t seems to work.
I didn’t find any documentations about that either.

Does anyone knows if it’s possible to add external bash completion files?
If yes, how to do it?

Thanks!

Possible it is, git and other packages do it, and your directory seems correct.

Did you installed the bash completion package? https://depot.haiku-os.org/#!/pkg/bash_completion/haikuports/haikuports_x86_64/2/11/-/-/2/any?bcguid=bc272-PCPP

Actually the correct directory should be
/boot/system/settings/etc/profile.d

Oh, well. :slightly_frowning_face: I have git completions in both directories.

A bit of investigation shows the one in etc/profile.d to be from an old version, while the current one uses data/bash-completion/completions due to Git package includes mksh incompatible shell includes in the default profile · Issue #9741 · haikuports/haikuports · GitHub. In this case, the script has bash-specific syntax that breaks in other shells, that also source etc/profile.d. The bash_completion package puts a little script there that checks the shell is bash in interactive mode and only in that case it sources the scripts in /system/data/bash-completion/completions.

So if the scripts in minipro already check what they need to work or at least not break in other shells, the correct place is indeed settings/etc/profile.d. If they don’t you should either patch them or put them in data/bash-completion/completions and have bash_completions to use them.

Thanks for the answers :smiley:

Looking at the git recipe, it definitely should be in data/bash-completion/completions so that should be fine.

I also have bash_completion installed.

I’m wondering if it’s not working because I installed minipro as a user package for testing instead of a system package :thinking:
I’ll try later to install it as a system package and see how it goes :smile:

Remove it and install it as system package.

Beware of the following issue with the bash_completion package:

IIRC, the problem is… the installed “hook” script contains a path with the version of the bash_completion package that was first installed. Newer versions will NOT overwrite that file, breaking completions.

Workaround… manually remove /boot/system/settings/etc/profile.d/bash_completion.sh, and reinstall bash_completion package.

“Proper” solution (for me at least) would be to patch it so the script doesn’t uses paths as /packages/bash_completion-2.11-2/.self/data/bash-completion/bash_completion, but just /system/data/bash-completion/bash_completion instead.

So the problem was that it was installed as a user package. It works fine as a system package ^^

Thanks everyone ;D

1 Like

Well, if that’s the case, then maybe we should patch that “hook” script so it also looks for completion helpers under ~/config/data/bash-completion/completions.

I might give it a go at some point (same with trying to fix the issue mentioned above), but stil hope someone with more experience than me beats me to it :slight_smile:.

Use $datadir variable instead of fixed paths?