From 57b54462300b2e62f5810cc77eb604f9479fd85c Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 13 Jul 2025 20:04:49 +0200 Subject: [PATCH] change command checks --- albentohandy | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/albentohandy b/albentohandy index 58f096d..a414ff8 100755 --- a/albentohandy +++ b/albentohandy @@ -1,5 +1,15 @@ #!/bin/bash +errlog() +{ + local lastexit=$? + local msg="$1" + + echo "❌ ERROR: $msg" + echo "🛑 EXIT $lastexit" + return $lastexit +} + Usage() { cat <<- EOF @@ -347,17 +357,32 @@ LoadConfig() source $HOME/.albentohandy.conf } -ExistsBasicProgramms() +check_programms() { - local program= - local readonly PROGRAMS="vorbiscomment flac oggenc parallel lame eyeD3 metaflac opusenc" - - for program in $PROGRAMS; do - if [ ! -f "/usr/bin/$program" ]; then - printf "$programm not installed\n" - exit 1 - fi - done + command -v flac > /dev/null \ + || errlog "command flac not found" \ + || return $? + command -v metaflac > /dev/null \ + || errlog "command metaflac not found" \ + || return $? + command -v oggenc > /dev/null \ + || errlog "command oggenc not found" \ + || return $? + command -v lame > /dev/null \ + || errlog "command lame not found" \ + || return $? + command -v opusenc > /dev/null \ + || errlog "command opusenc not found" \ + || return $? + command -v vorbiscomment > /dev/null \ + || errlog "command vorbiscomment not found" \ + || return $? + command -v eyeD3 > /dev/null \ + || errlog "command eyeD3 not found" \ + || return $? + command -v parallel > /dev/null \ + || errlog "command parallel not found" \ + || return $? } SetDefaultVariables() @@ -479,7 +504,7 @@ main() WORK="$(pwd)/work.$$" # temporary working directory MUSICPATH="/tmp/musikpath" # flac collection directory - ExistsBasicProgramms + check_programms || return $? LoadConfig SetDefaultVariables -- 2.47.3