The number after “FAIL” is the process's exit status. A process's exit status, as reported by the shell, is generally¹:
- 0 if the program exited normally and reported a success.
- 1 to 125 if the program exited normally and reported an error.
- 128+s if the program was killed by signal s, where s is a small integer.
141 means signal 13 which is SIGPIPE. Under the hood, the git command sets up a pipe between two subcommands: one subcommand gathers data and writes data to the pipe, and the other subcommand is the pager less
. If you don't view the whole output, the pager exits without waiting for the first subcommand to exit. When the first subcommand next tries to write to the pipe, it is killed by SIGPIPE. This is normal behavior, to avoid having commands continue to calculate and write output that nothing is reading.
There's nothing to fix. But if you find this distracting, you can change your theme to not report a failure status when it's SIGPIPE. The way to do that depends on your oh-my-zsh theme, but from what I can see with a quick look (I don't use oh-my-zsh), the ones that have the word FAIL do it by setting the PROMPT
variable, using a prompt expansion conditional to only print the FAIL stuff if the command's exit status is nonzero. So you'd need to change that to also take the “no-failure” branch if the exit status is 141. If you're using a theme bundled with oh-my-zsh, look for FAIL
in the theme definition ~/.oh-my-zsh/themes/$ZSH_THEME.zsh-theme
. Let's take the example of dst.zsh-theme
: the definition is
PROMPT='%(?, ,%{$fg[red]%}FAIL%{$reset_color%}
)
%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%}: %{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info)
$(prompt_char) '
(Note that it spans multiple lines.) The general pattern is %(?,IFSUCCESS,IFFAILURE)
to print IFSUCCESS
on success ($?
equals 0) and IFFAILURE
on failure (including signals). So we'll add another condition if $?
equals 141:
PROMPT='%(141?, ,%(?, ,%{$fg[red]%}FAIL%{$reset_color%}
))
%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%}: %{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info)
$(prompt_char) '
(Note that in addition to prepending %(141?, ,
, there's a matching closing parenthesis on the second line.)
¹ The details are off-topic here.
git
failed because it was killed by the system when it tried to write to a broken pipe. It's good that you have configuration in place that notifies you when a command you run fails. – Stéphane Chazelas Apr 25 '23 at 15:23