summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-05-05 07:49:11 -0300
committerEuAndreh <eu@euandre.org>2025-05-05 07:49:20 -0300
commit0b923a04119ed5fb2bef3cf02ae2280daac11920 (patch)
tree0394f9fd76aacda421d7cdf3702652ab12d8220a /src
parentAdd src/tac (diff)
downloadeut-0b923a04119ed5fb2bef3cf02ae2280daac11920.tar.gz
eut-0b923a04119ed5fb2bef3cf02ae2280daac11920.tar.xz
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.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/pre5
1 files changed, 1 insertions, 4 deletions
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 /"