diff --git a/async.zsh b/async.zsh index dce3af6..09c855b 100644 --- a/async.zsh +++ b/async.zsh @@ -213,7 +213,7 @@ async_process_results() { local caller=$3 local -a items local null=$'\0' data - integer -l len pos num_processed + integer -l len pos num_processed has_next typeset -gA ASYNC_PROCESS_BUFFER @@ -241,13 +241,14 @@ async_process_results() { pos=${ASYNC_PROCESS_BUFFER[$worker][(i)$null]} # Get index of NULL-character (delimiter). fi + has_next=$(( len != 0 )) if (( $#items == 5 )); then - items+=($(( len != 0 ))) + items+=($has_next) $callback "${(@)items}" # Send all parsed items to the callback. else # In case of corrupt data, invoke callback with *async* as job # name, non-zero exit status and an error message on stderr. - $callback "async" 1 "" 0 "$0:$LINENO: error: bad format, got ${#items} items (${(@q)items})" + $callback "async" 1 "" 0 "$0:$LINENO: error: bad format, got ${#items} items (${(@q)items})" $has_next fi (( num_processed++ ))