mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
49897: Eliminate reliance on $jobstates parameter, fix -P exit status check.
This commit is contained in:
parent
8154ddc62d
commit
67f932e7c5
1 changed files with 20 additions and 17 deletions
|
@ -43,14 +43,12 @@
|
||||||
# than 127 for "command not found" so this function incorrectly returns
|
# than 127 for "command not found" so this function incorrectly returns
|
||||||
# 123 in that case if used with zsh 4.0.x.
|
# 123 in that case if used with zsh 4.0.x.
|
||||||
#
|
#
|
||||||
# With the --max-procs option, zargs may not correctly capture the exit
|
# Because of "wait" limitations, --max-procs spawns max-procs jobs, then
|
||||||
# status of the backgrounded jobs, because of limitations of the "wait"
|
# waits for all of those, then spawns another batch, etc.
|
||||||
# builtin. If the zsh/parameter module is not available, the status is
|
|
||||||
# NEVER correctly returned, otherwise the status of the longest-running
|
|
||||||
# job in each batch is captured.
|
|
||||||
#
|
#
|
||||||
# Also because of "wait" limitations, --max-procs spawns max-procs jobs,
|
# The maximum number of parallel jobs for which exit status is available
|
||||||
# then waits for all of those, then spawns another batch, etc.
|
# is determined by the sysconf CHILD_MAX parameter, which can't be read
|
||||||
|
# or changed from within the shell.
|
||||||
#
|
#
|
||||||
# Differences from POSIX xargs:
|
# Differences from POSIX xargs:
|
||||||
#
|
#
|
||||||
|
@ -69,6 +67,9 @@
|
||||||
# -I/-L and implementations reportedly differ.) In zargs, -i/-I have
|
# -I/-L and implementations reportedly differ.) In zargs, -i/-I have
|
||||||
# this behavior, as do -l/-L, but when -i/-I appear anywhere then -l/-L
|
# this behavior, as do -l/-L, but when -i/-I appear anywhere then -l/-L
|
||||||
# are ignored (forced to 1).
|
# are ignored (forced to 1).
|
||||||
|
#
|
||||||
|
# * The use of SIGUSR1 and SIGUSR2 to change the number of parallel jobs
|
||||||
|
# is not supported.
|
||||||
|
|
||||||
# First, capture the current setopts as "sticky emulation"
|
# First, capture the current setopts as "sticky emulation"
|
||||||
if zmodload zsh/parameter
|
if zmodload zsh/parameter
|
||||||
|
@ -86,7 +87,7 @@ fi
|
||||||
emulate -L zsh || return 1
|
emulate -L zsh || return 1
|
||||||
local -a opts eof n s l P i
|
local -a opts eof n s l P i
|
||||||
|
|
||||||
local ZARGS_VERSION="1.5"
|
local ZARGS_VERSION="1.7"
|
||||||
|
|
||||||
if zparseopts -a opts -D -- \
|
if zparseopts -a opts -D -- \
|
||||||
-eof::=eof e::=eof \
|
-eof::=eof e::=eof \
|
||||||
|
@ -264,17 +265,19 @@ if (( P != 1 && ARGC > 1 ))
|
||||||
then
|
then
|
||||||
# These setopts are necessary for "wait" on multiple jobs to work.
|
# These setopts are necessary for "wait" on multiple jobs to work.
|
||||||
setopt nonotify nomonitor
|
setopt nonotify nomonitor
|
||||||
bg='&'
|
local -a _zajobs
|
||||||
if zmodload -i zsh/parameter 2>/dev/null
|
local j
|
||||||
then
|
bg='& _zajobs+=( $! )'
|
||||||
wait='wait ${${jobstates[(R)running:*]/#*:/}/%=*/}'
|
wait='wait'
|
||||||
else
|
analyze='
|
||||||
wait='wait'
|
for j in $_zajobs; do
|
||||||
fi
|
wait $j
|
||||||
|
'"$analyze"'
|
||||||
|
done; _zajobs=()'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Everything has to be in a subshell just in case of backgrounding jobs,
|
# Everything has to be in a subshell so that we don't "wait" for any
|
||||||
# so that we don't unintentionally "wait" for jobs of the parent shell.
|
# unrelated jobs of the parent shell.
|
||||||
(
|
(
|
||||||
|
|
||||||
while ((ARGC))
|
while ((ARGC))
|
||||||
|
|
Loading…
Reference in a new issue