fix: don't hang if there are jobs in the bg; close #523

This commit is contained in:
Jorge Bucaran 2019-01-30 03:33:03 +09:00
parent ae878a8e9c
commit c7472b2961
No known key found for this signature in database
GPG key ID: E54BA3C0E646DB30

View file

@ -258,6 +258,7 @@ function _fisher_parse -a mode cmd
end end
function _fisher_fetch function _fisher_fetch
set -l pkg_jobs
set -l out_pkgs set -l out_pkgs
set -l next_pkgs set -l next_pkgs
set -l local_pkgs set -l local_pkgs
@ -293,7 +294,6 @@ function _fisher_fetch
' | read -l url pkg branch ' | read -l url pkg branch
if test ! -d "$fisher_config/$pkg" if test ! -d "$fisher_config/$pkg"
set next_pkgs $next_pkgs "$fisher_config/$pkg"
fish -c " fish -c "
echo fetching $url >&2 echo fetching $url >&2
command mkdir -p $fisher_config/$pkg $fisher_cache/(command dirname $pkg) command mkdir -p $fisher_config/$pkg $fisher_cache/(command dirname $pkg)
@ -313,11 +313,13 @@ function _fisher_fetch
echo fisher: cannot add \"$pkg\" -- is this a valid package\? >&2 echo fisher: cannot add \"$pkg\" -- is this a valid package\? >&2
end end
" >/dev/null & " >/dev/null &
set pkg_jobs $pkg_jobs (_fisher_jobs --last)
set next_pkgs $next_pkgs "$fisher_config/$pkg"
end end
end end
if set -l jobs (_fisher_jobs) if set -q pkg_jobs[1]
while for job in $jobs while for job in $pkg_jobs
contains -- $job (_fisher_jobs); and break contains -- $job (_fisher_jobs); and break
end end
end end
@ -415,7 +417,7 @@ function _fisher_rm -a pkg
end end
function _fisher_jobs function _fisher_jobs
jobs $argv | command awk '/^[0-9]+\t/ { print (status = $1) } END { exit !status }' jobs $argv | command awk '/^[0-9]+\t/ { print $1 }'
end end
function _fisher_now -a elapsed function _fisher_now -a elapsed