diff --git a/bin/doorman.sh b/bin/doorman.sh index 17b35af..28a8d16 100755 --- a/bin/doorman.sh +++ b/bin/doorman.sh @@ -61,7 +61,10 @@ usage() { # behavior); Enter on an empty buffer emits nothing (defensive fix). # --------------------------------------------------------------------------- decode_stream() { # decode_stream — od -t u1 records on stdin -> IDs - awk -v w="$1" ' + # stdbuf exec's binaries only — it can NEVER wrap this function, so + # line-buffering happens here inside (piped awk block-buffers otherwise). + # shellcheck disable=SC2016 # awk program is single-quoted by design; '"$SELF"' re-opens quotes deliberately + stdbuf -oL awk -v w="$1" ' { if (NF != w) { next } ti = w - 7; ci = w - 5; vi = w - 3 @@ -143,7 +146,7 @@ stream_device() { log "listening on $dev (record width $WIDTH)" # stdbuf: od/awk block-buffer when piped; scans must not lag behind stdbuf -oL od -v -A n -t u1 -w"$WIDTH" "$dev" 2>/dev/null \ - | stdbuf -oL decode_stream "$WIDTH" \ + | decode_stream "$WIDTH" \ | while read -r bid; do process_scan "$bid" done