On Tue, Sep 30, 2025 at 11:25:20PM +0200, Timo Sigurdsson wrote:
>Sorry, I don't mean to bother you. But I made one more - and actually
>important - mistake.
>I tested my changed script with bash, and not dash. dash doesn't seem to
>support process substitution, so the attached diff does unfortunately not work
>as is.
>
>If you were to adopt my fix, the shebang would also need to be changed to
>bash. And that makes the fix actually a bit less simple.
Another drive-by, with a simpler fix (attached) to simply tee the output to a
temporary file and cat it at the end.
mktemp is in coreutils, which is essential, and this doesn't use any non-dash
syntax. Sending the output as email is delayed until the script finishes
anyway, so this should be equivalent.
Caveat: the diff attached is untested with systemd. I just ran it as:
sudo dash -xv cron.weekly
and it appeared to work as expected (although found no issues on my particular
machine).
--bod
--- cron.weekly.orig 2026-01-07 04:48:13.889299278 +0000
+++ cron.weekly 2026-01-07 04:52:28.453268911 +0000
@@ -19,9 +19,13 @@
IONICE="/usr/bin/ionice -c3"
fi
-exec 3>&1
+output=$(mktemp)
-$IONICE $debsums -cs 2>&1 | egrep -vf "$ignorefile" | tee /proc/self/fd/3 | sed 's/^debsums: //' | logger -t debsums
+$IONICE $debsums -cs 2>&1 | egrep -vf "$ignorefile" | tee "$output" | sed 's/^debsums: //' | logger -t debsums
+
+# Send a copy of output to email
+cat "$output"
+rm -f "$output"
# Exit with a normal status code even if errors (which could be ignored) were found
exit 0