mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
cleanup some undefined var references
Testing a fix for #4163 revealed some questionable dereferencing of variables that are not certain to be defined.
This commit is contained in:
parent
7904f92c9e
commit
3284393aba
3 changed files with 40 additions and 26 deletions
|
@ -5,6 +5,8 @@
|
|||
# Set default field separators
|
||||
#
|
||||
set -g IFS \n\ \t
|
||||
set -qg __fish_added_user_paths
|
||||
or set -g __fish_added_user_paths
|
||||
|
||||
#
|
||||
# Create the default command_not_found handler
|
||||
|
@ -175,23 +177,26 @@ end
|
|||
# Invoke it immediately to apply the current value of fish_user_path
|
||||
function __fish_reconstruct_path -d "Update PATH when fish_user_paths changes" --on-variable fish_user_paths
|
||||
set -l local_path $PATH
|
||||
set -l x
|
||||
|
||||
for x in $__fish_added_user_paths
|
||||
set -l idx (contains --index -- $x $local_path)
|
||||
and set -e local_path[$idx]
|
||||
end
|
||||
|
||||
set -e __fish_added_user_paths
|
||||
for x in $fish_user_paths[-1..1]
|
||||
if set -l idx (contains --index -- $x $local_path)
|
||||
set -e local_path[$idx]
|
||||
else
|
||||
set -g __fish_added_user_paths $__fish_added_user_paths $x
|
||||
set -g __fish_added_user_paths
|
||||
if set -q fish_user_paths
|
||||
for x in $fish_user_paths[-1..1]
|
||||
if set -l idx (contains --index -- $x $local_path)
|
||||
set -e local_path[$idx]
|
||||
else
|
||||
set -g __fish_added_user_paths $__fish_added_user_paths $x
|
||||
end
|
||||
set local_path $x $local_path
|
||||
end
|
||||
set local_path $x $local_path
|
||||
end
|
||||
set -xg PATH $local_path
|
||||
end
|
||||
|
||||
__fish_reconstruct_path
|
||||
|
||||
#
|
||||
|
@ -230,22 +235,23 @@ end
|
|||
# in UTF-8 (with non-ASCII characters).
|
||||
__fish_set_locale
|
||||
|
||||
# As last part of initialization, source the conf directories
|
||||
# Implement precedence (User > Admin > Extra (e.g. vendors) > Fish) by basically doing "basename"
|
||||
# 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 $configdir/fish/conf.d/*.fish $__fish_sysconfdir/conf.d/*.fish $__extra_confdir/*.fish
|
||||
set -l basename (string replace -r '^.*/' '' -- $file)
|
||||
contains -- $basename $sourcelist
|
||||
and continue
|
||||
set sourcelist $sourcelist $basename
|
||||
# Also skip non-files or unreadable files
|
||||
# This allows one to use e.g. symlinks to /dev/null to "mask" something (like in systemd)
|
||||
# Also skip non-files or unreadable files.
|
||||
# This allows one to use e.g. symlinks to /dev/null to "mask" something (like in systemd).
|
||||
[ -f $file -a -r $file ]
|
||||
and source $file
|
||||
end
|
||||
|
||||
# Upgrade pre-existing abbreviations from the old "key=value" to the new "key value" syntax
|
||||
# This needs to be in share/config.fish because __fish_config_interactive is called after 2sourcing config.fish, which might contain abbr calls
|
||||
# Upgrade pre-existing abbreviations from the old "key=value" to the new "key value" syntax.
|
||||
# This needs to be in share/config.fish because __fish_config_interactive is called after sourcing
|
||||
# config.fish, which might contain abbr calls.
|
||||
if not set -q __fish_init_2_3_0
|
||||
set -l fab
|
||||
for abb in $fish_user_abbreviations
|
||||
|
@ -261,11 +267,9 @@ end
|
|||
#
|
||||
|
||||
if status --is-login
|
||||
|
||||
#
|
||||
# Put linux consoles in unicode mode.
|
||||
#
|
||||
|
||||
if test "$TERM" = linux
|
||||
if string match -qir '\.UTF' -- $LANG
|
||||
if command -sq unicode_start
|
||||
|
|
|
@ -255,13 +255,18 @@ function __fish_config_interactive -d "Initializations that should be performed
|
|||
commandline -f repaint
|
||||
end
|
||||
|
||||
# Notify terminals when $PWD changes (issue #906)
|
||||
# VTE and Terminal.app support this in practice.
|
||||
if test "0$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal"
|
||||
# Notify terminals when $PWD changes (issue #906).
|
||||
# VTE based terminals, Terminal.app, and iTerm.app support this.
|
||||
set -q VTE_VERSION
|
||||
or set -l VTE_VERSION 0
|
||||
set -q TERM_PROGRAM
|
||||
or set -l TERM_PROGRAM
|
||||
if test "$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal" -o "$TERM_PROGRAM" = "iTerm.app"
|
||||
function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes'
|
||||
status --is-command-substitution
|
||||
or test -n "$INSIDE_EMACS"
|
||||
and return
|
||||
if status --is-command-substitution
|
||||
or set -q INSIDE_EMACS
|
||||
return
|
||||
end
|
||||
printf \e\]7\;file://\%s\%s\a (hostname) (string escape --style=url $PWD)
|
||||
end
|
||||
__update_cwd_osc # Run once because we might have already inherited a PWD from an old tab
|
||||
|
|
|
@ -16,8 +16,10 @@ function __fish_set_locale
|
|||
|
||||
# We check LC_ALL to figure out if we have a locale but we don't set it later. That is because
|
||||
# locale.conf doesn't allow it so we should not set it.
|
||||
if string length -q -- $$LOCALE_VARS $LC_ALL
|
||||
return 0
|
||||
for locale_var in $LOCALE_VARS LC_ALL
|
||||
if set -q $locale_var
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
# Unset all variables - they are empty anyway and this makes merging easier.
|
||||
|
@ -72,7 +74,10 @@ function __fish_set_locale
|
|||
end
|
||||
|
||||
# If we really cannot get anything, at least set character encoding to UTF-8.
|
||||
if not string length -q -- $$LOCALE_VARS $LC_ALL
|
||||
set -gx LC_CTYPE en_US.UTF-8
|
||||
for locale_var in $LOCALE_VARS LC_ALL
|
||||
if set -q $locale_var
|
||||
return 0
|
||||
end
|
||||
end
|
||||
set -gx LC_CTYPE en_US.UTF-8
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue