From 948efebe7137c334a20c4080da491f79d31d89d0 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 20 Apr 2021 14:14:46 +0200 Subject: shutdownasap: silence output of hooks, if -q --- shutdownasap.in | 19 ++++++++++++++++--- 1 file 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 -- cgit v1.2.3-70-g09d2