comparison .zfun/async @ 497:2ea29b487b06

zsh: update async to 1.8.5
author Augie Fackler <raf@durin42.com>
date Tue, 29 Sep 2020 11:11:09 -0400
parents d3d52766cfcd
children
comparison
equal deleted inserted replaced
496:1944a98a6774 497:2ea29b487b06
1 #!/usr/bin/env zsh 1 #!/usr/bin/env zsh
2 2
3 # 3 #
4 # zsh-async 4 # zsh-async
5 # 5 #
6 # version: v1.8.4 6 # version: v1.8.5
7 # author: Mathias Fredriksson 7 # author: Mathias Fredriksson
8 # url: https://github.com/mafredri/zsh-async 8 # url: https://github.com/mafredri/zsh-async
9 # 9 #
10 10
11 typeset -g ASYNC_VERSION=1.8.4 11 typeset -g ASYNC_VERSION=1.8.5
12 # Produce debug output from zsh-async when set to 1. 12 # Produce debug output from zsh-async when set to 1.
13 typeset -g ASYNC_DEBUG=${ASYNC_DEBUG:-0} 13 typeset -g ASYNC_DEBUG=${ASYNC_DEBUG:-0}
14 14
15 # Execute commands that can manipulate the environment inside the async worker. Return output via callback. 15 # Execute commands that can manipulate the environment inside the async worker. Return output via callback.
16 _async_eval() { 16 _async_eval() {
559 # Workaround for stderr in the main shell sometimes (incorrectly) being 559 # Workaround for stderr in the main shell sometimes (incorrectly) being
560 # reassigned to /dev/null by the reassignment done inside the async 560 # reassigned to /dev/null by the reassignment done inside the async
561 # worker. 561 # worker.
562 # See https://github.com/mafredri/zsh-async/issues/35. 562 # See https://github.com/mafredri/zsh-async/issues/35.
563 integer errfd=-1 563 integer errfd=-1
564 exec {errfd}>&2 564
565 # Redirect of errfd is broken on zsh 5.0.2.
566 if is-at-least 5.0.8; then
567 exec {errfd}>&2
568 fi
565 569
566 # Make sure async worker is started without xtrace 570 # Make sure async worker is started without xtrace
567 # (the trace output interferes with the worker). 571 # (the trace output interferes with the worker).
568 [[ -o xtrace ]] && { 572 [[ -o xtrace ]] && {
569 has_xtrace=1 573 has_xtrace=1
570 unsetopt xtrace 574 unsetopt xtrace
571 } 575 }
572 576
573 zpty -b $worker _async_worker -p $$ $args 2>&$errfd 577 if (( errfd != -1 )); then
578 zpty -b $worker _async_worker -p $$ $args 2>&$errfd
579 else
580 zpty -b $worker _async_worker -p $$ $args
581 fi
574 local ret=$? 582 local ret=$?
575 583
576 # Re-enable it if it was enabled, for debugging. 584 # Re-enable it if it was enabled, for debugging.
577 (( has_xtrace )) && setopt xtrace 585 (( has_xtrace )) && setopt xtrace
578 exec {errfd}>& - 586 (( errfd != -1 )) && exec {errfd}>& -
579 587
580 if (( ret )); then 588 if (( ret )); then
581 async_stop_worker $worker 589 async_stop_worker $worker
582 return 1 590 return 1
583 fi 591 fi