From 0b923a04119ed5fb2bef3cf02ae2280daac11920 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 5 May 2025 07:49:11 -0300 Subject: src/pre: Use sed(1) and handle buffering with stdbuf(1) The while loop and its variables where trimming the string undesirably: $ printf '\ta\n b\n' | pre -n out out a out b Previously, pre(1) would buffer its output if it wasn't a terminal, and I didn't want to add the proprietary -u flag to the sed(1) call. Now we use stdbuf(1) instead, and get the same behaviour, besides being much much faster. --- src/pre | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/pre b/src/pre index d593ad2..ec212d1 100755 --- a/src/pre +++ b/src/pre @@ -27,7 +27,4 @@ shift $((OPTIND - 1)) PREFIX="${1:-}" eval "$(assert-arg -- "$PREFIX" 'PREFIX')" -# FIXME: using "while" so we avoid GNU sed's buffering -while read -r line; do - printf '%s%s %s\n' "$PREFIX" "$SEP" "$line" -done +stdbuf -oL sed "s/^/$PREFIX$SEP /" -- cgit v1.2.3