diff --git a/music-sync.sh b/music-sync.sh index 7a8dcdf..c76f4eb 100755 --- a/music-sync.sh +++ b/music-sync.sh @@ -8,9 +8,8 @@ dest="-" verbose=2 help=false -GetOptions() { - - # https://stackoverflow.com/a/29754866 +CheckDeps() { + # Check getopt ! getopt --test > /dev/null if [[ ${PIPESTATUS[0]} -ne 4 ]]; then VerboseOutput 5 "\`getopt --test\` failed" @@ -19,7 +18,20 @@ GetOptions() { ExecTime exit 1 fi - + + # Check lame + if [[ ! $(lame --version 2>/dev/null) ]]; then + VerboseOutput 5 "\`lame --version\` failed" + VerboseOutput 5 "Sorry, It seems that lame is not installed on your system" + VerboseOutput 5 "Please install lame from your repositories and make sure it is available in your \$PATH" + ExecTime + exit 1 + fi +} + +GetOptions() { + + # https://stackoverflow.com/a/29754866 # Parsing style without -s or -d source=${*: -2:1} dest=${*: -1:1} @@ -221,6 +233,7 @@ ExecTime() { VerboseOutput 1 "$(($difftimelps / 60)) minutes and $(($difftimelps % 60)) seconds elapsed for Script Execution." } +CheckDeps GetOptions $@ if [[ $help == true ]]; then Usage