Created
November 2, 2023 22:20
-
-
Save WGH-/732193e083cccc5b78d690ab506d1c94 to your computer and use it in GitHub Desktop.
Weird flex: pv that reports its progress to systemd (needs NotifyAccess=all), e.g. for backup scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pv-systemd-notify() { | |
if [[ -v NOTIFY_SOCKET ]]; then | |
local f | |
function f { | |
stdbuf -oL tr '\r' '\n' | while IFS= read -r; do | |
systemd-notify --status="$REPLY" | |
done | |
} | |
pv -f 2> >(f) "$@" | |
else | |
pv "$@" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment