Skip to content

Commit

Permalink
Fix install location of openrc-service-script bash completion
Browse files Browse the repository at this point in the history
  • Loading branch information
williamh committed Jun 25, 2024
1 parent 70be1c0 commit 4dfec91
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bash-completion/meson.build
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
if get_option('bash-completions')
bash_completions = [
'openrc',
'openrc-service-script',
'rc-service',
'rc-status',
'rc-update',
]

install_data(bash_completions,
install_dir : get_option('datadir') / 'bash-completion/completions')
install_data(
'openrc-service-script',
install_dir : get_option('sysconfdir') / 'bash_completion.d')
endif

5 comments on commit 4dfec91

@markhindley
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really correct? Why does openrc-service-script need installing in a different location?

Certainly Debian expects them all to be in /usr/share/bash-completion/completions

Thanks

Mark

@eli-schwartz
Copy link

Choose a reason for hiding this comment

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

This is a fundamental failure to understand how bash completions work. And as a direct consequence, a failure to understand how Debian policy works.

I explained this in IRC when I advised this change, although the commit message doesn't mention these details.

Bash completion has two official completion directories:

  • completionsdir, a lazy loading mechanism
  • compatdir, an eager loading mechanism

Modern style is to use lazy loading if possible. It is modern technology, speeds up your shell by deferring loads, and generally recommended for applications to prefer by default. It requires you name your completion script using the same name as the command to complete. Every distro prefers you do this, but only because bash-completion itself does.

The openrc-service-script completion doesn't provide a completion for a command called openrc-service-script. It cannot use the lazy loading mechanism and emits a warning in Gentoo's policy lints as a result. Installing to the completionsdir is therefore a useless no-op. Better to install nothing.

The compatdir is the correct location for completions that cannot be lazy loaded and must be loaded at shell startup in order to correctly register themselves for a globbed list of commands that can only be ascertained dynamically at shell startup. The alternative is to have every command that can be globbed, install a symlink to openrc-service-script, and install openrc-service-script to a third location, but I'm not sure how great an experience that is...

@markhindley
Copy link
Contributor

@markhindley markhindley commented on 4dfec91 Jun 28, 2024 via email

Choose a reason for hiding this comment

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

@eli-schwartz
Copy link

Choose a reason for hiding this comment

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

Another option under discussion is to simply not install a completion script for /etc/init.d/* and expect people to simply use rc-service * to manage services. rc-service is a single predictable command linked to a single predictable completion, and hence is still installed to the modern lazy loading directory.

@williamh
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am fine with removing the completion for openrc-service-script and having people only use rc-service.

Please sign in to comment.