mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
Quote $USER when used with switch
or test
Common in prompts, this would fail if $USER is empty. See #4229.
This commit is contained in:
parent
3b92d99277
commit
e0f0164b16
12 changed files with 12 additions and 12 deletions
|
@ -5,7 +5,7 @@
|
|||
function fish_fallback_prompt --description "A simple fallback prompt without too much color or special characters for linux VTs"
|
||||
set -l color_cwd
|
||||
set -l suffix
|
||||
switch $USER
|
||||
switch "$USER"
|
||||
case root toor
|
||||
if set -q fish_color_cwd_root
|
||||
set color_cwd $fish_color_cwd_root
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
function fish_prompt --description "Write out the prompt"
|
||||
set -l color_cwd
|
||||
set -l suffix
|
||||
switch $USER
|
||||
switch "$USER"
|
||||
case root toor
|
||||
if set -q fish_color_cwd_root
|
||||
set color_cwd $fish_color_cwd_root
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
function fish_prompt --description "Write out the prompt"
|
||||
set -l color_cwd
|
||||
set -l suffix
|
||||
switch $USER
|
||||
switch "$USER"
|
||||
case root toor
|
||||
if set -q fish_color_cwd_root
|
||||
set color_cwd $fish_color_cwd_root
|
||||
|
|
|
@ -12,7 +12,7 @@ function fish_prompt --description "Write out the prompt"
|
|||
|
||||
set -l color_cwd
|
||||
set -l suffix
|
||||
switch $USER
|
||||
switch "$USER"
|
||||
case root toor
|
||||
if set -q fish_color_cwd_root
|
||||
set color_cwd $fish_color_cwd_root
|
||||
|
|
|
@ -49,7 +49,7 @@ function fish_prompt --description 'Write out the prompt'
|
|||
set -l color_cwd
|
||||
set -l prefix
|
||||
set -l suffix
|
||||
switch $USER
|
||||
switch "$USER"
|
||||
case root toor
|
||||
if set -q fish_color_cwd_root
|
||||
set color_cwd $fish_color_cwd_root
|
||||
|
|
|
@ -30,7 +30,7 @@ function fish_prompt --description 'Write out the prompt, prepending the Debian
|
|||
echo -n -s "$__fish_prompt_chroot_env" "$__fish_debian_chroot_prompt" "$__fish_prompt_normal" ' '
|
||||
end
|
||||
|
||||
switch $USER
|
||||
switch "$USER"
|
||||
|
||||
case root toor
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ function fish_prompt --description 'Write out the prompt'
|
|||
set __fish_color_status (set_color -o red)
|
||||
end
|
||||
|
||||
switch $USER
|
||||
switch "$USER"
|
||||
|
||||
case root toor
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ function fish_prompt --description 'Write out the prompt'
|
|||
set -l color_cwd
|
||||
set -l prefix
|
||||
set -l suffix
|
||||
switch $USER
|
||||
switch "$USER"
|
||||
case root toor
|
||||
if set -q fish_color_cwd_root
|
||||
set color_cwd $fish_color_cwd_root
|
||||
|
|
|
@ -16,7 +16,7 @@ function fish_prompt
|
|||
end
|
||||
set_color -o green
|
||||
echo -n [
|
||||
if test $USER = root -o $USER = toor
|
||||
if test "$USER" = root -o "$USER" = toor
|
||||
set_color -o red
|
||||
else
|
||||
set_color -o yellow
|
||||
|
|
|
@ -69,7 +69,7 @@ function fish_prompt
|
|||
end
|
||||
|
||||
set -l arrow "$arrow_color➜ "
|
||||
if [ $USER = 'root' ]
|
||||
if test "$USER" = 'root'
|
||||
set arrow "$arrow_color# "
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
function fish_prompt
|
||||
test $SSH_TTY
|
||||
and printf (set_color red)$USER(set_color brwhite)'@'(set_color yellow)(prompt_hostname)' '
|
||||
test $USER = 'root'
|
||||
test "$USER" = 'root'
|
||||
and echo (set_color red)"#"
|
||||
|
||||
# Main
|
||||
|
|
|
@ -5,7 +5,7 @@ function fish_prompt -d "Write out the prompt"
|
|||
set -l home_escaped (echo -n $HOME | sed 's/\//\\\\\//g')
|
||||
set -l pwd (echo -n $PWD | sed "s/^$home_escaped/~/" | sed 's/ /%20/g')
|
||||
set -l prompt_symbol ''
|
||||
switch $USER
|
||||
switch "$USER"
|
||||
case root toor
|
||||
set prompt_symbol '#'
|
||||
case '*'
|
||||
|
|
Loading…
Reference in a new issue