From fa145a58ef7ece2b48c126621fbbe96647e250d8 Mon Sep 17 00:00:00 2001 From: Mikhail Veltishchev Date: Tue, 22 Jul 2014 10:55:54 +0400 Subject: [PATCH 1/2] Check cuetools existance to avoid sh errors When cuetools package is not installed, split2flac will fail with cryptic error in sh script. So it's better to check that cuetools programs exist in the $PATH. --- split2flac | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/split2flac b/split2flac index f0a9ed2..f807a96 100755 --- a/split2flac +++ b/split2flac @@ -275,6 +275,14 @@ update_pattern () { update_pattern_aux "$v" "_${tag_name}" $(echo "${tag_value}" | sed "s/ /_/g") } +check_cuetools () { + if ! which cuebreakpoints 2>/dev/null ; then + emsg "'cuebreakpoints' tool was not found, " + emsg "you should install 'cuetools' package\n" + exit 1 + fi +} + # splits a file split_file () { TMPCUE="${HOME}/.split2flac_XXXXX.cue" @@ -423,6 +431,8 @@ split_file () { TAG_ALBUM=$(${GETTAG} %T "${CUE}" 2>/dev/null) TRACKS_NUM=$(${GETTAG} %N "${CUE}" 2>/dev/null) + check_cuetools + # some cue sheets may have non-audio tracks # we can check the difference between what cuebreakpoints and cueprint gives us BREAKPOINTS_NUM=$(($(cuebreakpoints "${CUE}" 2>/dev/null | wc -l) + 1)) From 9c1042120ff3a9d60caf7bcf64a6081a46d9aa1c Mon Sep 17 00:00:00 2001 From: Mikhail Veltishchev Date: Tue, 22 Jul 2014 11:02:36 +0400 Subject: [PATCH 2/2] Check shntool tools existance. --- split2flac | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/split2flac b/split2flac index f807a96..b7c008c 100755 --- a/split2flac +++ b/split2flac @@ -283,6 +283,14 @@ check_cuetools () { fi } +check_shntool () { + if ! which shnsplit 2>/dev/null ; then + emsg "'shnsplit' tool was not found, " + emsg "you should install 'shntool' package\n" + exit 1 + fi +} + # splits a file split_file () { TMPCUE="${HOME}/.split2flac_XXXXX.cue" @@ -512,6 +520,8 @@ split_file () { *) emsg "Unknown output format ${FORMAT}\n"; exit 1;; esac + check_shntool + # split to tracks # sed expression is a fix for "shnsplit: error: m:ss.ff format can only be used with CD-quality files" cuebreakpoints "${CUE}" 2>/dev/null | \