mirror of
https://github.com/linuxboot/heads.git
synced 2025-02-13 06:05:19 +00:00
etc/functions: Fix SINK_LOG blank lines, add more dev doc
Add examples for capturing stderr or both stdout+stderr. Trace blank lines with LOG like non-blank lines. Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm> Signed-off-by: Thierry Laurion <insurgo@riseup.net>
This commit is contained in:
parent
283553956f
commit
516f7b6924
@ -402,6 +402,15 @@ mask_param() {
|
||||
#
|
||||
# For example:
|
||||
# ls /boot/vmlinux* | SINK_LOG "/boot kernels"
|
||||
#
|
||||
# To capture stderr:
|
||||
# cryptsetup open /dev/sda1 media-crypt 2> >(SINK_LOG "LUKS unlock sda1 errors")
|
||||
# (Note: the space between '>' is necessary in '2> >(SINK_LOG ...)')
|
||||
#
|
||||
# To capture both:
|
||||
# tpm reset > >(SINK_LOG "tpm reset") 2>&1
|
||||
# (Note: 2>&1 must follow the stdout redirection, and space between '>' is
|
||||
# necessary)
|
||||
SINK_LOG() {
|
||||
local name="$1"
|
||||
local line haveblank
|
||||
@ -413,7 +422,7 @@ SINK_LOG() {
|
||||
cat
|
||||
echo
|
||||
) | while IFS= read -r line; do
|
||||
[[ -n "$haveblank" ]] && DEBUG "$name: " # Emit buffered blank line
|
||||
[[ -n "$haveblank" ]] && LOG "$name: " # Emit buffered blank line
|
||||
if [[ -z "$line" ]]; then
|
||||
haveblank=y
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user