summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2021-04-20 14:14:46 +0200
committerErich Eckner <git@eckner.net>2021-04-20 14:14:46 +0200
commit948efebe7137c334a20c4080da491f79d31d89d0 (patch)
treea9d3dbd6826c592e2206e5757173f8d98672a468
parent1dc8b055dbe40f266073a50aea011e7f02d3b757 (diff)
downloadshutdownasap-948efebe7137c334a20c4080da491f79d31d89d0.tar.xz
shutdownasap: silence output of hooks, if -q
-rwxr-xr-xshutdownasap.in19
1 files changed, 16 insertions, 3 deletions
diff --git a/shutdownasap.in b/shutdownasap.in
index d131867..69c8d71 100755
--- a/shutdownasap.in
+++ b/shutdownasap.in
@@ -40,10 +40,23 @@ fi
echo $$ > "${tmpDir}/pid"
+capture_output() {
+ local exit_code
+ local output
+ output=$(
+ "$@" 2>&1 \
+ || exit_code=$?
+ )
+ if ! ${quiet}; then
+ printf '%s\n' "${output}"
+ fi
+ return ${exit_code}
+}
+
beforeWatchHook
i=1
-while [ ${i} -gt 0 ] || ! additionalWatchHookSlow
+while [ ${i} -gt 0 ] || ! cypture_output additionalWatchHookSlow
do
if [ ${i} -eq 0 ]
then
@@ -110,7 +123,7 @@ do
fi
done
- if ! additionalWatchHookFast
+ if ! cypture_output additionalWatchHookFast
then
nochwarten=true
if ! ${quiet}; then
@@ -133,7 +146,7 @@ do
i=$[${i}-1]
done
-beforeShutDownHook
+cypture_output beforeShutDownHook
if command -v sudo >/dev/null \
&& [ "$(whoami)" != 'root' ]; then