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 | 27 | # ART: ImageMagick |
| 28 | 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 | 36 | CONFIG="${HOME}/.split2flac" |
| 31 | 37 | TMPCUE="${HOME}/.split2flac_sheet.cue" |
| 32 | 38 | TMPPIC="${HOME}/.split2flac_cover.jpg" |
| @@ -139,7 +145,7 @@ while [ "$1" ]; do · 106 unmodified lines | ||
| 139 | 145 | exit 1 |
| 140 | 146 | elif [ ! -r "$1" ]; then |
| 141 | 147 | emsg "Unable to read $1" |
| 142 | − exit 1 | |
| 148 | + exit 2 | |
| 143 | 149 | else |
| 144 | 150 | INPATH="$1" |
| 145 | 151 | fi;; |
| @@ -520,28 +526,28 @@ split_collection () { · 374 unmodified lines | ||
| 520 | 526 | echo |
| 521 | 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 | 529 | if [ ${NUM_FAILED} -ne 0 ]; then |
| 533 | 530 | emsg "${NUM_FAILED} file(s) failed to split (already splited?):" |
| 534 | 531 | $msg "${cR}" |
| 535 | 532 | sort "${FAILED}" -o "${FAILED}" |
| 536 | 533 | cat "${FAILED}" |
| 537 | 534 | emsg "\nThese files are also listed in ${FAILED}." |
| 535 | + return 1 | |
| 538 | 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 | 547 | if [ -d "${INPATH}" ]; then |
| 542 | 548 | if [ ! -x "${INPATH}" ]; then |
| 543 | 549 | emsg "Directory \"${INPATH}\" is not accessible" |
| 544 | − exit 1 | |
| 550 | + exit 2 | |
| 545 | 551 | fi |
| 546 | 552 | $msg "${cG}Input dir :$cZ ${INPATH}$cZ\n" |
| 547 | 553 | split_dir "${INPATH}" |
| @@ -552,4 +558,11 @@ else · 4 unmodified lines | ||
| 552 | 558 | exit 1 |
| 553 | 559 | fi |
| 554 | 560 | |
| 561 | +# return code of split_dir or split_file | |
| 562 | +STATUS=$? | |
| 563 | + | |
| 555 | 564 | $msg "\n${cP}Finished$cZ" |
| 565 | + | |
| 566 | +if [ ${STATUS} -ne 0 ]; then | |
| 567 | + exit 3 | |
| 568 | +fi | |