From fea095b433a4045f41f8ae9f4be91bb35b812e1c Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Thu, 2 Mar 2023 13:25:29 +0100 Subject: [PATCH] sequencer - fix sqr::log output not seen in additinal pipe output --- sequencer.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sequencer.sh b/sequencer.sh index 5c4d1be..846bdeb 100755 --- a/sequencer.sh +++ b/sequencer.sh @@ -411,7 +411,7 @@ USAGE_API local newline='\n' local col_end= col_end="$(col off)" - local outp='/dev/stdout' + local outerr=0 local log_level="${1:-}" shift @@ -428,7 +428,8 @@ USAGE_API case "${arg}" in a) appendText=1 ;; d) direct=1 ;; - e) outp='/dev/stderr' ;; + e) outerr=1 + exec 8>&1 9>&2 >&2;; n) newline='' ;; *) ;; esac @@ -441,30 +442,32 @@ USAGE_API local log_line="" while IFS=$'\n' read -r log_line ; do - printf '%b' "${log_color}" >${outp} + printf '%b' "${log_color}" if ! (( direct )) ; then if [[ -n "${LOG_TIME}" ]] ; then if (( appendText )) ; then - printf '%19s' "" >${outp} + printf '%19s' "" else - printf '%s' "$(date +"%Y-%m-%d %H:%M:%S")" >${outp} + printf '%s' "$(date +"%Y-%m-%d %H:%M:%S")" fi fi if (( ! appendText )) ; then - printf " %3s " "[${log_level}]" >${outp} - printf "%s" "${log_line}" >${outp} + printf " %3s " "[${log_level}]" + printf "%s" "${log_line}" else # +4 : " [] " - printf "%$((${#log_level} + 4))s%s" "" "${log_line}" >${outp} + printf "%$((${#log_level} + 4))s%s" "" "${log_line}" fi else # direct output printf '%s' "${log_line}" fi - printf '%b'"${newline}" "${col_end}" >${outp} + printf '%b'"${newline}" "${col_end}" done <<< "${@:-}" + (( outerr )) && exec 1>&8 2>&9 + return 0 sqr::debugContinue }