From c7e6baa908d287063ff1c21e823a058ec411cef2 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 9 May 2025 09:01:56 +0000 Subject: [PATCH] Fix. --- testing/copy/desktop/home/plom/.local/bin/vol | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/testing/copy/desktop/home/plom/.local/bin/vol b/testing/copy/desktop/home/plom/.local/bin/vol index 837988b..3481e01 100755 --- a/testing/copy/desktop/home/plom/.local/bin/vol +++ b/testing/copy/desktop/home/plom/.local/bin/vol @@ -33,8 +33,11 @@ USAGE_DESC_LOUDNESS="volume to set (as percentage, should be integer <= ${MAX_LO -error_exit() { - abort "Aborting due to $1\n\n$(print_usage)" +abort_bad_args() { + echo "Aborting due to unrecognized argument(s): $@" >&2 + echo "" + print_usage + exit 1 } set_target_device() { @@ -58,7 +61,7 @@ toggle_mute() { set_volume_as_percentage() { _PERCENTAGE=$(echo "$1" | tr -d '%') if [ "${_PERCENTAGE}" -gt "${MAX_LOUDNESS}" ]; then - error_exit "demand for unreasonably high loudness: ${_PERCENTAGE}%." + abort "Aborting due to demand for unreasonably high loudness: ${_PERCENTAGE}%." fi AT_FULL=65536 pacmd set-${TARGET_TYPE}-volume "${TARGET_IDX}" $(calc "(${_PERCENTAGE} * ${AT_FULL} // 100)") @@ -78,6 +81,7 @@ if [ "$(echo $1 | cut -c1)" = '-' ]; then set_target_device 'microphone' 1 'source' else error_exit "unrecognized argument: $1" + abort_bad_args $@ fi shift 1 fi @@ -86,5 +90,5 @@ if [ -z "$1" ]; then elif [ -z "$(echo -n $1 | sed -E 's/[0-9]*[%]?//g')" ]; then set_volume_as_percentage "$1" else - error_exit "unrecognized argument: $1" + abort_bad_args $@ fi -- 2.30.2