Skip to content

Commit 20c7b4a

Browse files
committed
No need to fork on Zsh >= 5.8
1 parent 62f8066 commit 20c7b4a

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

agkozak-zsh-prompt.plugin.zsh

+15-10
Original file line numberDiff line numberDiff line change
@@ -626,19 +626,24 @@ _agkozak_async_init() {
626626

627627
typeset -g AGKOZAK_ASYNC_FD=13371
628628

629-
if [[ $OSTYPE == (msys|cygwin) ]]; then
630-
exec {AGKOZAK_ASYNC_FD} < <(_agkozak_branch_status; command true)
631-
elif [[ $OSTYPE == solaris* ]]; then
629+
# There was a bug in Zsh < 5.8 that required forking
630+
if is-at-least 5.8; then
632631
exec {AGKOZAK_ASYNC_FD} < <(_agkozak_branch_status)
633-
command sleep 0.01
634-
elif [[ $ZSH_VERSION == 5.0.[0-2] ]]; then
635-
exec {AGKOZAK_ASYNC_FD} < <(_agkozak_branch_status)
636-
command sleep 0.02
637632
else
638-
exec {AGKOZAK_ASYNC_FD} < <(_agkozak_branch_status)
633+
if [[ $OSTYPE == (msys|cygwin) ]]; then
634+
exec {AGKOZAK_ASYNC_FD} < <(_agkozak_branch_status; command true)
635+
elif [[ $OSTYPE == solaris* ]]; then
636+
exec {AGKOZAK_ASYNC_FD} < <(_agkozak_branch_status)
637+
command sleep 0.01
638+
elif [[ $ZSH_VERSION == 5.0.[0-2] ]]; then
639+
exec {AGKOZAK_ASYNC_FD} < <(_agkozak_branch_status)
640+
command sleep 0.02
641+
else
642+
exec {AGKOZAK_ASYNC_FD} < <(_agkozak_branch_status)
639643

640-
# Bug workaround; see http://www.zsh.org/mla/workers/2018/msg00966.html
641-
command true
644+
# Bug workaround; see http://www.zsh.org/mla/workers/2018/msg00966.html
645+
command true
646+
fi
642647
fi
643648

644649
zle -F "$AGKOZAK_ASYNC_FD" _agkozak_zsh_subst_async_callback

0 commit comments

Comments
 (0)