@ -525,6 +525,8 @@ function gitstatus_start"${1:-}"() {
local -i lock_fd resp_fd stderr_fd
local file_prefix xtrace = /dev/null daemon_log = /dev/null
{
if ( ( _GITSTATUS_STATE_$name ) ) ; then
( ( async ) ) && return
( ( _GITSTATUS_STATE_$name = = 2 ) ) && return
@ -617,35 +619,6 @@ function gitstatus_start"${1:-}"() {
[ [ $req_fd = = <1-> ] ] || return
typeset -gi _GITSTATUS_REQ_FD_$name = req_fd
function _gitstatus_process_response_$name -$fsuf ( ) {
emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent
local pair = ${ ${ (%) :- %N } #_gitstatus_process_response_ }
local name = ${ pair %%-* }
local fsuf = ${ pair #*- }
if ( ( ARGC = = 1 ) ) ; then
_gitstatus_process_response$fsuf $name 0 ''
else
gitstatus_stop$fsuf $name
fi
}
if ! zle -F $resp_fd _gitstatus_process_response_$name -$fsuf ; then
unfunction _gitstatus_process_response_$name -$fsuf
return 1
fi
function _gitstatus_cleanup_$name -$fsuf ( ) {
emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent
local pair = ${ ${ (%) :- %N } #_gitstatus_cleanup_ }
local name = ${ pair %%-* }
local fsuf = ${ pair #*- }
( ( _GITSTATUS_CLIENT_PID_$name = = sysparams[ pid] ) ) || return
gitstatus_stop$fsuf $name
}
if ! add-zsh-hook zshexit _gitstatus_cleanup_$name -$fsuf ; then
unfunction _gitstatus_cleanup_$name -$fsuf
return 1
fi
print -nru $req_fd -- $'hello\x1f\x1e' || return
local expected = $'hello\x1f0\x1e' actual
if ( ( $+functions[ p10k] ) ) && [ [ ! -t 1 && ! -t 0 ] ] ; then
@ -705,6 +678,36 @@ function gitstatus_start"${1:-}"() {
done
[ [ $actual = = $expected ] ] || return
function _gitstatus_process_response_$name -$fsuf ( ) {
emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent
local pair = ${ ${ (%) :- %N } #_gitstatus_process_response_ }
local name = ${ pair %%-* }
local fsuf = ${ pair #*- }
[ [ $name = = POWERLEVEL9K && $fsuf = = _p9k_ ] ] && eval $__p9k_intro_base
if ( ( ARGC = = 1 ) ) ; then
_gitstatus_process_response$fsuf $name 0 ''
else
gitstatus_stop$fsuf $name
fi
}
if ! zle -F $resp_fd _gitstatus_process_response_$name -$fsuf ; then
unfunction _gitstatus_process_response_$name -$fsuf
return 1
fi
function _gitstatus_cleanup_$name -$fsuf ( ) {
emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent
local pair = ${ ${ (%) :- %N } #_gitstatus_cleanup_ }
local name = ${ pair %%-* }
local fsuf = ${ pair #*- }
( ( _GITSTATUS_CLIENT_PID_$name = = sysparams[ pid] ) ) || return
gitstatus_stop$fsuf $name
}
if ! add-zsh-hook zshexit _gitstatus_cleanup_$name -$fsuf ; then
unfunction _gitstatus_cleanup_$name -$fsuf
return 1
fi
if ( ( lock_fd != -1 ) ) ; then
zf_rm -- $file_prefix .lock || return
zsystem flock -u $lock_fd || return
@ -714,7 +717,7 @@ function gitstatus_start"${1:-}"() {
typeset -gi _GITSTATUS_STATE_$name = 2
fi
}
} always {
local -i err = $?
( ( stderr_fd ) ) && exec 2>& $stderr_fd { stderr_fd} >& -
( ( err = = 0 ) ) && return
@ -722,6 +725,7 @@ function gitstatus_start"${1:-}"() {
gitstatus_stop$fsuf $name
setopt prompt_percent no_prompt_subst no_prompt_bang
print -ru2 -- ''
print -Pru2 -- '[%F{red}ERROR%f]: gitstatus failed to initialize.'
print -ru2 -- ''
print -ru2 -- ' Your Git prompt may disappear or become slow.'
@ -776,8 +780,7 @@ function gitstatus_start"${1:-}"() {
print -ru2 -- ''
print -ru2 -- ' With this parameter gitstatus will print additional information on error.'
fi
return err
}
}
# Stops gitstatusd if it's running.