Skip to content

Commit

Permalink
Load vendor configuration directories outside prefix
Browse files Browse the repository at this point in the history
Vendor configuration provided by third party packages is sourced first
from $EXTRA_VENDOR_PATH/vendor_* and $PREFIX/share/fish/vendor_*
instead of only the latter.  The default for $EXTRA_VENDOR_PATH is
/usr/local/share/fish:/usr/share/fish, which enables fish to source
third party configuration from packages installed there, even if fish is
installed with a different prefix. The directories in $EXTRA_VENDOR_PATH
will not be created by (installing) fish.

In particular, with this change
/usr/bin/fish also uses /usr/local/share/fish/vendor_completions.d, and
/usr/local/bin/fish also uses /usr/share/fish/vendor_completions.d

Fixes fish-shell#5029
  • Loading branch information
krobelus committed Dec 13, 2019
1 parent 1f83fb4 commit e06b4f8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -146,6 +146,7 @@
- The `INTERNAL_WCWIDTH` build option has been removed, as fish now always uses an internal `wcwidth` function. It has a number of configuration options that make it more suitable for general use (#5777).
- mandoc can now be used to format the output from `--help` if `nroff` is not installed, reducing the number of external dependencies on systems with `mandoc` installed (#5489).
- Some bugs preventing building on Solaris-derived systems such as Illumos were fixed (#5458, #5461, #5611).
- Vendored configuration like completions and functions are sourced first from `{/usr/local,/usr}/share/fish/vendor_{completions,conf,functions}.d` and second from `$PREFIX/share/fish/vendor_{completions,conf,functions}.d` . Previously, only the latter was used. The former paths can be customized using the CMake variable `EXTRA_VENDOR_PATH`; set it to an empty string to restore the old behavior (#5029).

---

Expand Down
6 changes: 5 additions & 1 deletion cmake/Install.cmake
Expand Up @@ -16,6 +16,10 @@ SET(mandir ${CMAKE_INSTALL_MANDIR})

SET(rel_datadir ${CMAKE_INSTALL_DATADIR})
SET(datadir ${CMAKE_INSTALL_FULL_DATADIR})
SET(EXTRA_VENDOR_PATH "/usr/local/share/fish:/usr/share/fish" CACHE PATH
"Additional prefix to look for third-party completions, configuration and \
functions. This directory is usually not managed by a package manager, \
this is to support locally installed software.")

SET(docdir ${CMAKE_INSTALL_DOCDIR})

Expand All @@ -30,7 +34,7 @@ SET(extra_completionsdir

SET(extra_functionsdir
${datadir}/fish/vendor_functions.d
CACHE STRING "Path for extra completions")
CACHE STRING "Path for extra functions")

SET(extra_confdir
${datadir}/fish/vendor_conf.d
Expand Down
4 changes: 1 addition & 3 deletions share/__fish_build_paths.fish.in
Expand Up @@ -3,6 +3,4 @@
# the local "vendor" completions, functions and configuration conf.
# It is sourced by share/config.fish, if it exists.

set __extra_completionsdir @extra_completionsdir@
set __extra_functionsdir @extra_functionsdir@
set __extra_confdir @extra_confdir@
set __EXTRA_VENDOR_PATH @EXTRA_VENDOR_PATH@
15 changes: 9 additions & 6 deletions share/config.fish
Expand Up @@ -47,26 +47,29 @@ end
# __fish_data_dir, __fish_sysconf_dir, __fish_help_dir, __fish_bin_dir
# are expected to have been set up by read_init from fish.cpp

set -l __EXTRA_VENDOR_PATH
# Grab extra directories (as specified by the build process, usually for
# third-party packages to ship completions &c.
set -l __extra_completionsdir
set -l __extra_functionsdir
set -l __extra_confdir
if test -f $__fish_data_dir/__fish_build_paths.fish
source $__fish_data_dir/__fish_build_paths.fish
end

# Set up function and completion paths. Make sure that the fish
# default functions/completions are included in the respective path.

set -l vendor_data_dirs $__EXTRA_VENDOR_PATH
if not contains -- $__fish_data_dir $vendor_data_dirs # Ensure that $PREFIX/share/fish/vendor_* is included.
set -a vendor_data_dirs $__fish_data_dir
end

if not set -q fish_function_path
set fish_function_path $__fish_config_dir/functions $__fish_sysconf_dir/functions $__extra_functionsdir $__fish_data_dir/functions
set fish_function_path $__fish_config_dir/functions $__fish_sysconf_dir/functions $vendor_data_dirs/vendor_functions.d $__fish_data_dir/functions
else if not contains -- $__fish_data_dir/functions $fish_function_path
set -a fish_function_path $__fish_data_dir/functions
end

if not set -q fish_complete_path
set fish_complete_path $__fish_config_dir/completions $__fish_sysconf_dir/completions $__extra_completionsdir $__fish_data_dir/completions $__fish_user_data_dir/generated_completions
set fish_complete_path $__fish_config_dir/completions $__fish_sysconf_dir/completions $vendor_data_dirs/vendor_completions.d $__fish_data_dir/completions $__fish_user_data_dir/generated_completions
else if not contains -- $__fish_data_dir/completions $fish_complete_path
set -a fish_complete_path $__fish_data_dir/completions
end
Expand Down Expand Up @@ -249,7 +252,7 @@ end
# As last part of initialization, source the conf directories.
# Implement precedence (User > Admin > Extra (e.g. vendors) > Fish) by basically doing "basename".
set -l sourcelist
for file in $__fish_config_dir/conf.d/*.fish $__fish_sysconf_dir/conf.d/*.fish $__extra_confdir/*.fish
for file in $__fish_config_dir/conf.d/*.fish $__fish_sysconf_dir/conf.d/*.fish $vendor_data_dirs/vendor_conf.d/*.fish
set -l basename (string replace -r '^.*/' '' -- $file)
contains -- $basename $sourcelist
and continue
Expand Down

0 comments on commit e06b4f8

Please sign in to comment.