Update zsh-async to fix multi-space path bug
If a directory was named `hello world` (two spaces) this would previously have resulted in pure trying to `cd` into `hello world` (one space) to perform git actions. This issue was fixed in zsh-async 1.3.0. There might also have been other cases, e.g. a newline in the directory name.
This commit is contained in:
33
async.zsh
33
async.zsh
@@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# zsh-async
|
# zsh-async
|
||||||
#
|
#
|
||||||
# version: 1.2.0
|
# version: 1.3.0
|
||||||
# author: Mathias Fredriksson
|
# author: Mathias Fredriksson
|
||||||
# url: https://github.com/mafredri/zsh-async
|
# url: https://github.com/mafredri/zsh-async
|
||||||
#
|
#
|
||||||
@@ -26,7 +26,7 @@ _async_job() {
|
|||||||
unset stdout stderr ret
|
unset stdout stderr ret
|
||||||
eval "$(
|
eval "$(
|
||||||
{
|
{
|
||||||
stdout=$(eval "$@")
|
stdout=$(eval '$@')
|
||||||
ret=$?
|
ret=$?
|
||||||
typeset -p stdout ret
|
typeset -p stdout ret
|
||||||
} 2> >(stderr=$(cat); typeset -p stderr)
|
} 2> >(stderr=$(cat); typeset -p stderr)
|
||||||
@@ -91,9 +91,21 @@ _async_worker() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
while read -r cmd; do
|
local -a buffer
|
||||||
# Separate on spaces into an array
|
# Command arguments are separated with a null character.
|
||||||
cmd=(${=cmd})
|
while read -r -d $'\0' line; do
|
||||||
|
if [[ $line != ___ZSH_ASNYC_EOC___ ]]; then
|
||||||
|
# Read command arguments until we receive magic end-of-command string.
|
||||||
|
buffer+=($line)
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy command buffer
|
||||||
|
cmd=("${(@)=buffer}")
|
||||||
|
|
||||||
|
# Reset command buffer
|
||||||
|
buffer=()
|
||||||
|
|
||||||
local job=$cmd[1]
|
local job=$cmd[1]
|
||||||
|
|
||||||
# Check for non-job commands sent to worker
|
# Check for non-job commands sent to worker
|
||||||
@@ -223,7 +235,14 @@ async_job() {
|
|||||||
setopt localoptions noshwordsplit
|
setopt localoptions noshwordsplit
|
||||||
|
|
||||||
local worker=$1; shift
|
local worker=$1; shift
|
||||||
zpty -w $worker $@
|
|
||||||
|
local cmd p
|
||||||
|
for p in "$@"; do
|
||||||
|
cmd+="$p"$'\0'
|
||||||
|
done
|
||||||
|
cmd+=___ZSH_ASNYC_EOC___$'\0'
|
||||||
|
|
||||||
|
zpty -w $worker $cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function traps notification signals and calls all registered callbacks
|
# This function traps notification signals and calls all registered callbacks
|
||||||
@@ -283,7 +302,7 @@ async_flush_jobs() {
|
|||||||
zpty -t $worker &>/dev/null || return 1
|
zpty -t $worker &>/dev/null || return 1
|
||||||
|
|
||||||
# Send kill command to worker
|
# Send kill command to worker
|
||||||
zpty -w $worker "_killjobs"
|
async_job $worker "_killjobs"
|
||||||
|
|
||||||
# Clear all output buffers
|
# Clear all output buffers
|
||||||
while zpty -r $worker line; do true; done
|
while zpty -r $worker line; do true; done
|
||||||
|
|||||||
Reference in New Issue
Block a user