Skip to content

Further improvements to bash-completion - #126

Merged
mschwan-phytec merged 10 commits into
mainfrom
wip-bash-completion
Nov 20, 2026
Merged

mschwan-phytec merged 10 commits into
mainfrom
wip-bash-completion

Conversation

@mschwan-phytec

Copy link
Copy Markdown
Collaborator

Improve the bash-completion for partup to support all options and commands. Use Meson to install the completions. Add an entry to the changelog and add documentation.

@s-hemer s-hemer left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have issues with the changed script: it does not complete --help after command? IMHO it should i.e. for 'install' complete directories, partup files and all available options? I kind of highjacked the mechanism to do no further completions also after --version, so first after command it also did complete --version. I do not see an issue with filenames: you just shoudl not use a file named i.e. --help? Didn't test as touch and vim also just execute the help printout instead of generation a file...
Beside, I do not really get the reasoning behind installing in a shell subdirectory? In Ubuntu, the common completion install directory is /etc/bash_completion.d/, so here won't be any bloat or misconfig with other shells.

@mschwan-phytec

mschwan-phytec commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

It does complete options after a command if you start with one or two dashes (- + TAB or -- + TAB), e.g.: partup install - and pressing TAB twice, but by default expects a path as the next argument. This is the same behavior as e.g. git.

The reason for putting the completion script in a completions/bash/ subdirectory, is that there are more shells with their own, different implementation of completions. E.g. zsh uses a different syntax, and I want to prepare the structure supporting these.

The usual place for system-wide bash completion scripts is in /usr/share/bash-completion/completions (even on Ubuntu). /etc/bash_completion.d/ is "outdated" and was primarily used on old init.d-style systems.

@mschwan-phytec

Copy link
Copy Markdown
Collaborator Author

@s-hemer I've added you to the list of contributors in the AUTHORS.rst file: dd7c56e I hope that's okay for you.

@s-hemer s-hemer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it looks like on friday I did not really get the change of path: that is just in the sources, install is still to a "bash-" subfolder anyways (if /etc/ or /usr/share/ does not matter...).
With the option completion: ok, git does is this way, potentially others as well so it is ok for me. Yet, I am still unsure if I really like it that way as to a certain extend, it looks like one cannot add options at that step...
I am fine with me adding to contributors although this PR kind of re-writes my whole contribution so far...

@s-hemer

s-hemer commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

One additional comment: installing via meson is also ok for me, yet why do we need the Debian files at all? Can't those be generated by meson completely? We now install to pkgconfig bash_completion_dir (which likely is /usr/share/bash-completion/...), yet the debian/dirs does not contain it?!

@mschwan-phytec

Copy link
Copy Markdown
Collaborator Author

One additional comment: installing via meson is also ok for me, yet why do we need the Debian files at all? Can't those be generated by meson completely?

No. Unfortunately, Meson cannot generate a complete Debian package by itself.

We now install to pkgconfig bash_completion_dir (which likely is /usr/share/bash-completion/...), yet the debian/dirs does not contain it?!

Good point. The debian/dirs file can probably be omitted, as directories are already automatically generated by Meson instead.

The initial draft did not complete the arguments of options and mixed
up several details. Rework the script so that all commands, options and
positional arguments complete correctly.

- Skip the arguments of -D/--debug-domains and -C/--directory when
  looking for the command, so that e.g. a file named like a command is
  not mistaken for it.
- Complete only directories for -C/--directory, also in the
  --directory=DIR form, and nothing for -D/--debug-domains.
- Complete the PACKAGE and DEVICE arguments of install by position and
  only offer one PACKAGE for show.
- Offer the help options only directly after a command.
- Add the SPDX license header and prefix all variables and functions
  with _partup_ to avoid polluting the shell environment.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Install the completion script as 'partup' into the bash-completion
directory reported by pkg-config. Fall back to the default location
below datadir if bash-completion is not installed, so that the script
is available for all packaging and not only for Debian.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Meson now installs the completion script, so dh_bash-completion would
only duplicate it. Drop the extra install file and the debhelper
sequence addition. Keep bash-completion as a build dependency, as meson
queries it with pkg-config for the install location.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Document the Bash completion script, what it completes and how to use
it without installing partup.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Add the Bash completion script to the release notes of the upcoming
release.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Keep shell completion scripts in a dedicated completions/ directory with
one subdirectory per shell, so that scripts for other shells can be added
later without cluttering the top-level directory. Name the script after
the command, as it is installed, so that the meson install rule no
longer needs to rename it. Update the documentation accordingly.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
When installing partup in this workflow, use sudo, as required for files
owned by root.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Add Steffen Hemer as a new contributor for his work on bash completion
support.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
The debian/dirs file is redundant and not needed, as the directory
structure is already created by Meson Build.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Add the bash-completion package to the build container for building
Debian packages. This is required for bash completion to successfully
build into the Debian package.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
@mschwan-phytec
mschwan-phytec merged commit ec5a303 into main Nov 20, 2026
4 of 8 checks passed
@mschwan-phytec
mschwan-phytec deleted the wip-bash-completion branch November 20, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants