0 - success 1 - error in arguments 2 - file or path is not accessible 3 - something has failed
Unified · Split
| @@ -27,6 +27,12 @@ · 26 unmodified lines | |||
| 27 | # ART: ImageMagick | 27 | # ART: ImageMagick |
| 28 | # CHARSET: iconv | 28 | # CHARSET: iconv |
| 29 | 29 | ||
| 30 | # Return codes: | ||
| 31 | # 0 - success | ||
| 32 | # 1 - error in arguments | ||
| 33 | # 2 - file or path is not accessible | ||
| 34 | # 3 - something has failed | ||
| 35 | |||
| 30 | CONFIG="${HOME}/.split2flac" | 36 | CONFIG="${HOME}/.split2flac" |
| 31 | TMPCUE="${HOME}/.split2flac_sheet.cue" | 37 | TMPCUE="${HOME}/.split2flac_sheet.cue" |
| 32 | TMPPIC="${HOME}/.split2flac_cover.jpg" | 38 | TMPPIC="${HOME}/.split2flac_cover.jpg" |
| @@ -139,7 +145,7 @@ while [ "$1" ]; do · 106 unmodified lines | |||
| 139 | exit 1 | 145 | exit 1 |
| 140 | elif [ ! -r "$1" ]; then | 146 | elif [ ! -r "$1" ]; then |
| 141 | emsg "Unable to read $1" | 147 | emsg "Unable to read $1" |
| 142 | exit 1 | 148 | exit 2 |
| 143 | else | 149 | else |
| 144 | INPATH="$1" | 150 | INPATH="$1" |
| 145 | fi;; | 151 | fi;; |
| @@ -520,28 +526,28 @@ split_collection () { · 374 unmodified lines | |||
| 520 | echo | 526 | echo |
| 521 | done | 527 | done |
| 522 | 528 | ||
| 523 | return ${NUM_FAILED} | ||
| 524 | } | ||
| 525 | |||
| 526 | # searches for files in a directory and splits them | ||
| 527 | split_dir () { | ||
| 528 | rm -f "${FAILED}" | ||
| 529 | find "$1" -iname '*.flac' -o -iname '*.ape' -o -iname '*.wv' | split_collection | ||
| 530 | NUM_FAILED=$? | ||
| 531 | |||
| 532 | if [ ${NUM_FAILED} -ne 0 ]; then | 529 | if [ ${NUM_FAILED} -ne 0 ]; then |
| 533 | emsg "${NUM_FAILED} file(s) failed to split (already splited?):" | 530 | emsg "${NUM_FAILED} file(s) failed to split (already splited?):" |
| 534 | $msg "${cR}" | 531 | $msg "${cR}" |
| 535 | sort "${FAILED}" -o "${FAILED}" | 532 | sort "${FAILED}" -o "${FAILED}" |
| 536 | cat "${FAILED}" | 533 | cat "${FAILED}" |
| 537 | emsg "\nThese files are also listed in ${FAILED}." | 534 | emsg "\nThese files are also listed in ${FAILED}." |
| 535 | return 1 | ||
| 538 | fi | 536 | fi |
| 537 | |||
| 538 | return 0 | ||
| 539 | } | ||
| 540 | |||
| 541 | # searches for files in a directory and splits them | ||
| 542 | split_dir () { | ||
| 543 | rm -f "${FAILED}" | ||
| 544 | find "$1" -iname '*.flac' -o -iname '*.ape' -o -iname '*.wv' | split_collection | ||
| 539 | } | 545 | } |
| 540 | 546 | ||
| 541 | if [ -d "${INPATH}" ]; then | 547 | if [ -d "${INPATH}" ]; then |
| 542 | if [ ! -x "${INPATH}" ]; then | 548 | if [ ! -x "${INPATH}" ]; then |
| 543 | emsg "Directory \"${INPATH}\" is not accessible" | 549 | emsg "Directory \"${INPATH}\" is not accessible" |
| 544 | exit 1 | 550 | exit 2 |
| 545 | fi | 551 | fi |
| 546 | $msg "${cG}Input dir :$cZ ${INPATH}$cZ\n" | 552 | $msg "${cG}Input dir :$cZ ${INPATH}$cZ\n" |
| 547 | split_dir "${INPATH}" | 553 | split_dir "${INPATH}" |
| @@ -552,4 +558,11 @@ else · 4 unmodified lines | |||
| 552 | exit 1 | 558 | exit 1 |
| 553 | fi | 559 | fi |
| 554 | 560 | ||
| 561 | # return code of split_dir or split_file | ||
| 562 | STATUS=$? | ||
| 563 | |||
| 555 | $msg "\n${cP}Finished$cZ" | 564 | $msg "\n${cP}Finished$cZ" |
| 565 | |||
| 566 | if [ ${STATUS} -ne 0 ]; then | ||
| 567 | exit 3 | ||
| 568 | fi | ||