mirror of
https://github.com/linuxboot/heads.git
synced 2025-02-19 00:40:31 +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:
|
# For example:
|
||||||
# ls /boot/vmlinux* | SINK_LOG "/boot kernels"
|
# 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() {
|
SINK_LOG() {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
local line haveblank
|
local line haveblank
|
||||||
@ -413,7 +422,7 @@ SINK_LOG() {
|
|||||||
cat
|
cat
|
||||||
echo
|
echo
|
||||||
) | while IFS= read -r line; do
|
) | 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
|
if [[ -z "$line" ]]; then
|
||||||
haveblank=y
|
haveblank=y
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user