Package: busybox Version: 1:1.22.0-6 Severity: wishlist Dear Maintainer,
In udebs, it is common to redirect the standard output of a command to a fifo, and use that to display progress bars in the installer. trap 'kill $pid' EXIT /path/to/command >"$fifo" & while read -u 7 n; do db_progress SET $n done 7< "$fifo" rm -f "$fifo" trap - EXIT However, if the command buffers its standard output, which for instance is what cryptsetup(8) does, and/or if the standard output needs to be piped through sed(1) (which also buffers its standard streams), it's hard to make sense of the progress bar, which suddenly jumps from 0% to 100% while nothing happens in the meantime. cryptsetup -q --key-file="$keyfile" luksFormat "$device" | \ sed -nr 's/^Generating key \(([0-9]+)% done\)\.$/\1/p' > "$fifo" & It'd be convenient to provide a way to disable buffering in STDOUT, in the fashion of stdbuf(1) from GNU coreutils [1]. If the full blown stdbuf(1) is overkill, it might still be desirable to add a strip down version disabling buffering only, as found in [2]: :/lib/stdbuf.c #include <stdio.h> __attribute__ ((constructor)) void QLqxcKVd20zweBii () { setvbuf (stdout, NULL, _IOLBF, 0); } $ gcc -Wall -x c -s /lib/stdbuf.c -fPIC -shared -o /lib/stdbuf.so :/bin/stdbuf #!/bin/sh LD_PRELOAD=/lib/stdbuf.so "$@" Then buffering of STDOUT could be disabled as follows: stdbuf cryptsetup -q --key-file="$keyfile" luksFormat "$device" | \ stdbuf sed -nr 's/^Generating key \(([0-9]+)% done\)\.$/\1/p' > "$fifo" & Thanks! Cheers, -- Guilhem. [1] http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/stdbuf.c [2] https://lists.gnu.org/archive/html/bug-coreutils/2008-11/msg00138.html -- System Information: Debian Release: jessie/sid APT prefers unstable APT policy: (990, 'unstable'), (800, 'testing'), (700, 'stable'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 3.14-1-686-pae (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages busybox depends on: ii libc6 2.19-1 busybox recommends no packages. busybox suggests no packages. -- no debconf information
signature.asc
Description: Digital signature