print_pipestatus: Simplify

Just some minor stylistic nits
This commit is contained in:
Fabian Homborg 2020-09-24 20:08:16 +02:00
parent a776b08e84
commit dde8318e50

View file

@ -8,21 +8,28 @@ function __fish_print_pipestatus --description "Print pipestatus for prompt"
set -l left_brace $argv[1] set -l left_brace $argv[1]
set -l right_brace $argv[2] set -l right_brace $argv[2]
set -l separator $argv[3] set -l separator $argv[3]
set -l brace_sep_color $argv[4]
set -l status_color $argv[5] # Colors default to normal
set -q argv[4]
and set -l brace_sep_color $argv[4]
or set -l brace_sep_color normal
set -q argv[5]
and set -l status_color $argv[5]
or set -l status_color normal
set -e argv[1 2 3 4 5] set -e argv[1 2 3 4 5]
# Only print status codes if the job failed. # Only print status codes if the job failed.
# SIGPIPE (141 = 128 + 13) is usually not a failure, see #6375. # SIGPIPE (141 = 128 + 13) is usually not a failure, see #6375.
if test $last_status -ne 0 && test $last_status -ne 141 if not contains $last_status 0 141
set -l sep (set_color normal){$brace_sep_color}{$separator}(set_color normal){$status_color} set -l sep $brace_sep_color$separator$status_color
set -l last_pipestatus_string (string join "$sep" (__fish_pipestatus_with_signal $argv)) set -l last_pipestatus_string (__fish_pipestatus_with_signal $argv | string join "$sep")
set -l last_status_string "" set -l last_status_string ""
if test $last_status -ne $argv[-1] if test $last_status -ne $argv[-1]
set last_status_string " "$status_color$last_status set last_status_string " "$status_color$last_status
end end
printf "%s%s%s%s%s%s%s%s%s%s%s" (set_color normal )$brace_sep_color $left_brace \ printf "%s" $brace_sep_color $left_brace \
(set_color normal) $status_color $last_pipestatus_string (set_color normal) \ $status_color $last_pipestatus_string \
$brace_sep_color $right_brace $last_status_string (set_color normal) $brace_sep_color $right_brace $last_status_string (set_color normal)
end end
end end