diff options
author | EuAndreh <eu@euandre.org> | 2025-05-05 07:49:11 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2025-05-05 07:49:20 -0300 |
commit | 0b923a04119ed5fb2bef3cf02ae2280daac11920 (patch) | |
tree | 0394f9fd76aacda421d7cdf3702652ab12d8220a /src | |
parent | Add src/tac (diff) | |
download | eut-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-x | src/pre | 5 |
1 files changed, 1 insertions, 4 deletions
@@ -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 /" |