From 870f351bf157332c5c6c5392317e0b9a8ccb7ab0 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Thu, 26 Jul 2018 09:43:22 +0300 Subject: [PATCH] Invoke callback with has next even in error cases --- async.zsh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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++ ))