Download raw body.
check_sym: do not run output commands twice
src/lib/check_sym has a function output_if_not_empty() that wraps
the output of some command, but only if there is any. To do this,
it runs the command, checks if there is any output, then RUNS IT
AGAIN.
Ewww.
The good news is that we can achieve the same by piping whatever
output there is through a single sed invocation. The addresses 1
and $ only trigger if there is any input.
The bad news, well, it's sed.
OK?
-----------------------------------------------
commit 2efd5e35040658fa02336c5633ab824c84ddc081 (local)
from: Christian Weisgerber <naddy@mips.inka.de>
date: Mon May 11 22:44:05 2026 UTC
check_sym: do not run output commands twice
diff cbfc2be66f713e85e01430423dcb36ac0c25092f 2efd5e35040658fa02336c5633ab824c84ddc081
commit - cbfc2be66f713e85e01430423dcb36ac0c25092f
commit + 2efd5e35040658fa02336c5633ab824c84ddc081
blob - e51de0d98e481c487338ff0214331b0d1c3eda5f
blob + 20ce3a47ca937b74308eb9067b091271a1f7cb1e
--- lib/check_sym
+++ lib/check_sym
@@ -130,12 +130,13 @@ output_if_not_empty()
{
leader=$1
shift
- if "$@" | grep -q .
- then
- echo "$leader"
- "$@" | sed 's:^: :'
- echo
- fi
+ "$@" | sed '
+1i\
+'"$leader"'
+s:^: :
+$a\
+
+'
}
--
Christian "naddy" Weisgerber naddy@mips.inka.de
check_sym: do not run output commands twice