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:
Fabian Homborg 2017-07-20 19:45:32 +02:00
parent 3b92d99277
commit e0f0164b16
12 changed files with 12 additions and 12 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 '*'