mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 06:05:39 +08:00
Work around absent `string' in old fishies upgrading.
Improves experience during upgrades, accidentally running an old fish with a new environment. No errors just from printing a prompt. Fixes #3057. Print helpful notice also when launching mismatched fish. Autoloadable string.fish -- only create function if not builtin.
This commit is contained in:
parent
ecf4517ffe
commit
dfb4998778
|
@ -18,8 +18,23 @@ function __fish_default_command_not_found_handler
|
|||
end
|
||||
|
||||
if status --is-interactive
|
||||
# Existance of string is a good pre-2.3.0 check. Could also check $FISH_VERSION in the future.
|
||||
# This is a "launch", not an issue caused by autoloading during upgrades.
|
||||
if not contains "string" (builtin -n)
|
||||
# the string.fish message to `exec` will probably not help here, so this will that.
|
||||
set -g __is_launched_without_string 1
|
||||
|
||||
set_color --bold
|
||||
echo "You appear to be trying to launch an old fish binary with newer scripts "
|
||||
echo "installed into" (set_color --underline)"$__fish_datadir"
|
||||
set_color normal
|
||||
echo -e "\nThis is an unsupported configuration.\n"
|
||||
set_color yellow
|
||||
echo "You may need to uninstall and reinstall fish!"
|
||||
set_color normal
|
||||
else
|
||||
# Enable truecolor/24-bit support for select terminals
|
||||
if not set -q NVIM_LISTEN_ADDRESS # Neovim will swallow the 24bit sequences, rendering text white
|
||||
if not set -q NVIM_LISTEN_ADDRESS # (Neovim will swallow the 24bit sequences, rendering text white)
|
||||
and begin
|
||||
set -q KONSOLE_PROFILE_NAME # KDE's konsole
|
||||
or string match -q -- "*:*" $ITERM_SESSION_ID # Supporting versions of iTerm2 will include a colon here
|
||||
|
@ -30,6 +45,7 @@ if status --is-interactive
|
|||
# Only set it if it isn't to allow override by setting to 0
|
||||
set -q fish_term24bit; or set -g fish_term24bit 1
|
||||
end
|
||||
end
|
||||
else
|
||||
# Hook up the default as the principal command_not_found handler
|
||||
# in case we are not interactive
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
function __fish_urlencode --description "URL-encode stdin"
|
||||
if not type -q string
|
||||
return 1
|
||||
end
|
||||
|
||||
set -l join ''
|
||||
set -l chars
|
||||
# Set locale to C and IFS to "" in order to split a line into bytes.
|
||||
|
|
|
@ -5,6 +5,12 @@ function prompt_pwd --description "Print the current working directory, shortene
|
|||
return 0
|
||||
end
|
||||
|
||||
# If we don't have a string builtin, we have no hope of maniuplating $PWD - just output it as-is.
|
||||
if not type -q string
|
||||
echo $PWD
|
||||
return 0
|
||||
end
|
||||
|
||||
# This allows overriding fish_prompt_pwd_dir_length from the outside (global or universal) without leaking it
|
||||
set -q fish_prompt_pwd_dir_length; or set -l fish_prompt_pwd_dir_length 1
|
||||
|
||||
|
|
16
share/functions/string.fish
Normal file
16
share/functions/string.fish
Normal file
|
@ -0,0 +1,16 @@
|
|||
if not contains string (builtin -n)
|
||||
function string
|
||||
if not set -q __is_launched_without_string
|
||||
if status --is-interactive
|
||||
# We've been autoloaded after fish < 2.3.0 upgraded to >= 2.3.1 - no string builtin
|
||||
set_color --bold
|
||||
echo "Fish has been upgraded, and the scripts on your system are not compatible"
|
||||
echo "with this prior instance of fish. You can probably run:"
|
||||
set_color green
|
||||
echo "\n exec fish"
|
||||
set_color normal
|
||||
echo "… to replace this process with a new one in-place."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user