Jan Schaumann on Nostr: TIL: #NetBSD / macOS lets you change stdio buffering behavior via the STDBUF env ...
TIL: #NetBSD / macOS lets you change stdio buffering behavior via the STDBUF env variable (see setbuf(3)). Similar to GNU stdbuf(1), but a lot less cumbersome:
Default behavior, pipe I/O is fully buffered, wait forever to get output:
while sleep 1; do echo TEST; done | grep . | grep .
Make it line-buffered:
export STDBUF=L; while ...
Buffer 25 bytes:
export STDBUF=F25; while ...
Via Julia Evans (npub1hyj…avly)/112995960680348851">https://mstdn.social/Julia Evans (npub1hyj…avly)/112995960680348851 and https://blog.plover.com/Unix/stdio-buffering-2.html.
Default behavior, pipe I/O is fully buffered, wait forever to get output:
while sleep 1; do echo TEST; done | grep . | grep .
Make it line-buffered:
export STDBUF=L; while ...
Buffer 25 bytes:
export STDBUF=F25; while ...
Via Julia Evans (npub1hyj…avly)/112995960680348851">https://mstdn.social/Julia Evans (npub1hyj…avly)/112995960680348851 and https://blog.plover.com/Unix/stdio-buffering-2.html.