Don't branch on __fish_data_dir[1] in standalone builds

We use absence of "$__fish_data_dir[1]" as criteria to use the
"standalone" code paths that use "status list-files/get-file" instead
of $__fish_data_dir.

However, third party software seems slow to react to such breaking
changes, see https://github.com/ajeetdsouza/zoxide/issues/1045

So keep $__fish_data_dir for now to give plugins more time.
This commit makes us ignore $__fish_data_dir on standalone builds
even if defined; a  following commit will actually define it again.

I guess the approach in b815fff292 (Set $__fish_data_dir to empty
for embed-data builds, 2025-04-01) made sense back when we didn't
anticipate switching to standalone builds by default yet.
This commit is contained in:
Johannes Altmanninger
2025-10-26 23:08:22 +01:00
parent 8d02987c64
commit c409e816df
9 changed files with 63 additions and 25 deletions

View File

@@ -22,21 +22,28 @@ if not status --is-interactive
end
end
# N.B. can't load __fish_is_standalone.fish this early in non-embedded builds, so reimplement it.
# We still want it as a separate file for --no-config.
set -l is_standalone (
if status get-file config.fish &>/dev/null
echo true
else
echo false
end
)
#
# Set default search paths for completions and shellscript functions
# unless they already exist
#
# __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
# 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
# N.B. can't load __fish_data_with_file this early in non-embedded builds, so reimplement it.
if status get-file __fish_build_paths.fish &>/dev/null
if $is_standalone
status get-file __fish_build_paths.fish | source
else if path is -f -- $__fish_data_dir/__fish_build_paths.fish
source $__fish_data_dir/__fish_build_paths.fish
@@ -48,7 +55,7 @@ set -l xdg_data_dirs
if set -q XDG_DATA_DIRS
set --path xdg_data_dirs $XDG_DATA_DIRS
set xdg_data_dirs (string replace -r '([^/])/$' '$1' -- $xdg_data_dirs)/fish
else
else if not $is_standalone
set xdg_data_dirs $__fish_data_dir
end
@@ -77,14 +84,21 @@ end
# default functions/completions are included in the respective path.
if not set -q fish_function_path
set fish_function_path $__fish_config_dir/functions $__fish_sysconf_dir/functions $__fish_vendor_functionsdirs $__fish_data_dir/functions
else if not contains -- $__fish_data_dir/functions $fish_function_path
set fish_function_path $__fish_config_dir/functions $__fish_sysconf_dir/functions $__fish_vendor_functionsdirs
if not $is_standalone
set -a fish_function_path $__fish_data_dir/functions
end
else if not $is_standalone; and 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 $__fish_vendor_completionsdirs $__fish_data_dir/completions $__fish_cache_dir/generated_completions
else if not contains -- $__fish_data_dir/completions $fish_complete_path
set fish_complete_path $__fish_config_dir/completions $__fish_sysconf_dir/completions $__fish_vendor_completionsdirs
if not $is_standalone
set -a fish_complete_path $__fish_data_dir/completions
end
set -a fish_complete_path $__fish_cache_dir/generated_completions
else if not $is_standalone; and not contains -- $__fish_data_dir/completions $fish_complete_path
set -a fish_complete_path $__fish_data_dir/completions
end

View File

@@ -1,7 +1,7 @@
# localization: skip(private)
function __fish_data_list_files
set -l dir $argv[1]
if set -q __fish_data_dir[1]
if not __fish_is_standalone
# Construct a directory prefix without trailing slash.
if test -n "$dir"
set dir $__fish_data_dir/$dir

View File

@@ -5,7 +5,7 @@ function __fish_data_with_directory
set -l cmd $argv[3..]
set -l temp
set -l directory_ref
if set -q __fish_data_dir[1]
if not __fish_is_standalone
set directory_ref $__fish_data_dir/$relative_directory
else
set temp (__fish_mktemp_relative -d fish-data)

View File

@@ -3,7 +3,7 @@ function __fish_data_with_file
set -l path $argv[1]
set -l cmd $argv[2..]
if string match -rq -- ^/ $path; or begin
set -q __fish_data_dir[1]
not __fish_is_standalone
and set path $__fish_data_dir/$path
end
$cmd $path

View File

@@ -0,0 +1,11 @@
# localization: skip(private)
set -l is_standalone (
if status get-file config.fish &>/dev/null
echo true
else
echo false
end
)
function __fish_is_standalone -V is_standalone
$is_standalone
end

View File

@@ -38,8 +38,11 @@ function __fish_print_help_pre_4.1 --description "Print help message for the spe
set -l item $argv[1]
set -l error_message $argv[2]
# Do nothing if the file does not exist
if not path is -- $__fish_data_dir/man/man1/$item.1 $__fish_data_dir/man/man1/$item.1.gz
and not status get-file man/man1/$item.1 >/dev/null
if not if __fish_is_standalone
status get-file man/man1/$item.1 >/dev/null
else
path is -- $__fish_data_dir/man/man1/$item.1 $__fish_data_dir/man/man1/$item.1.gz
end
return 2
end
@@ -71,7 +74,7 @@ function __fish_print_help_pre_4.1 --description "Print help message for the spe
return 1
end
if path is -- $__fish_data_dir/man/man1/$item.1
if __fish_is_standalone; and path is -- $__fish_data_dir/man/man1/$item.1
# Some nroff versions screw up non-ascii characters.
# (even with the locale set correctly!)
# Work around that by running preconv first.
@@ -80,7 +83,7 @@ function __fish_print_help_pre_4.1 --description "Print help message for the spe
else
set help ($format "$__fish_data_dir/man/man1/$item.1" 2>/dev/null)
end
else if path is -- $__fish_data_dir/man/man1/$item.1.gz
else if __fish_is_standalone; and path is -- $__fish_data_dir/man/man1/$item.1.gz
if command -sq preconv; and test "$format[1]" = nroff
set help (gunzip -c "$__fish_data_dir/man/man1/$item.1.gz" 2>/dev/null | preconv -e UTF-8 | $format 2>/dev/null)
else

View File

@@ -287,7 +287,7 @@ fish_pager_color_secondary_description
if not set -q theme_path[1]
echo >&2 "No such theme: $argv[1]"
echo >&2 Searched (__fish_config_theme_dirs) (
if not set -q __fish_data_dir[1]
if __fish_is_standalone
echo "and `status list-files tools/web_config/themes`"
end
)
@@ -332,7 +332,10 @@ fish_pager_color_secondary_description
end
function __fish_config_list_prompts
set -lx dirs $__fish_data_dir/tools/web_config/sample_prompts
set -lx dirs
if not __fish_is_standalone
set dirs $__fish_data_dir/tools/web_config/sample_prompts
end
set -l prompt_paths (__fish_config_matching tools/web_config/sample_prompts .fish $argv)
if [ (count $argv) = 1 ] && set -q prompt_paths[2]
echo >&2 "fish_config: internal error: multiple prompts matching '$argv' ??"
@@ -347,9 +350,10 @@ function __fish_config_list_themes
end
function __fish_config_theme_dirs
printf %s\n \
$__fish_config_dir/themes \
$__fish_data_dir/tools/web_config/themes
printf %s\n $__fish_config_dir/themes
if not __fish_is_standalone
printf %s\n $__fish_data_dir/tools/web_config/themes
end
end
function __fish_config_list_theme_names
@@ -368,7 +372,7 @@ function __fish_config_matching
else
set paths (path filter $dirs/$argv$suffix)
end
if not set -q __fish_data_dir[1]
if __fish_is_standalone
if not set -q argv[1]
set -a paths (status list-files $prefix)
else

View File

@@ -20,10 +20,16 @@ function fish_delta
end
# TODO: Do we want to keep the vendor dirs in here?
set -l default_function_path $__fish_data_dir/functions
set -l default_function_path
if not __fish_is_standalone
set default_function_path $__fish_data_dir/functions
end
test "$vendormode" = default && set -a default_function_path $__fish_vendor_functionsdirs
set -l default_complete_path $__fish_data_dir/completions
set -l default_complete_path
if not __fish_is_standalone
set default_complete_path $__fish_data_dir/completions
end
test "$vendormode" = default && set -a default_complete_path $__fish_vendor_completionsdirs
set -l default_conf_path

View File

@@ -33,7 +33,7 @@ function man
set -lx MANPATH $manpath
# Prepend fish's man directory if available.
if set -q __fish_data_dir[1]
if not __fish_is_standalone
set -l fish_manpath $__fish_data_dir/man
if test -d $fish_manpath
set MANPATH $fish_manpath $MANPATH