Skip to content

Commit

Permalink
Completion: Hard-code directories where to install completion scripts
Browse files Browse the repository at this point in the history
Requiring having a shell installed at build-time to get the appropriate
location won't cover the cases like when a system has such a location
set to a non-standard path.

The use of fallbacks together with hardcoded paths also increases the
complexity of this particular feature.

All 3 major shells (Bash, Zsh, Fish) have documented default directories
where they look for completion scripts and we can make use of that.
Additionaly, hard-coding of these paths seems to be the standard among
projects.

Fallout from containers#840

containers#1055
  • Loading branch information
HarryMichal committed May 20, 2022
1 parent 33af1f1 commit 803d628
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
18 changes: 4 additions & 14 deletions completion/meson.build
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
if bash_completion.found()
bash_comp_dir = bash_completion.get_pkgconfig_variable('completionsdir')
else
bash_comp_dir = get_option('datadir') / 'bash-completion' / 'completions'
message('bash-completion not found: using', get_option('prefix') / bash_comp_dir, 'as a falback install directory')
endif

if fish.found()
fish_comp_dir = fish.get_pkgconfig_variable('completionsdir')
else
fish_comp_dir = get_option('datadir') / 'fish' / 'completions'
message('fish not found: using', get_option('prefix') / fish_comp_dir, 'as a fallback install directory')
endif
bash_comp_dir = get_option('datadir') / 'bash-completion' / 'completions'
zsh_comp_dir = get_option('datadir') / 'zsh' / 'site-functions'
fish_comp_dir = get_option('datadir') / 'fish' / 'vendor_completions.d'

completion_bash = custom_target('bash-completion',
capture: true,
Expand All @@ -23,7 +13,7 @@ completion_zsh = custom_target('zsh-completion',
capture: true,
command: [toolbox, 'completion', 'zsh'],
install: true,
install_dir: get_option('datadir') / 'zsh' / 'site-functions',
install_dir: zsh_comp_dir,
output: '_toolbox')

completion_fish = custom_target('fish-completion',
Expand Down
3 changes: 0 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ go_md2man = find_program('go-md2man')
shellcheck = find_program('shellcheck', required: false)
skopeo = find_program('skopeo', required: false)

bash_completion = dependency('bash-completion', required: false)
fish = dependency('fish', required: false)

migration_path_for_coreos_toolbox = get_option('migration_path_for_coreos_toolbox')
profiledir = get_option('profile_dir')

Expand Down

0 comments on commit 803d628

Please sign in to comment.