History

return codes (issue #1)

0 - success 1 - error in arguments 2 - file or path is not accessible 3 - something has failed

Serge Zirukin committed 16 years ago

Commit 33248ca1 parent 81142bb1 file · +24 −11Browse files

Unified · Split

split2flac.sh+24−11
@@ -27,6 +27,12 @@ · 26 unmodified lines
27# ART: ImageMagick27# ART: ImageMagick
28# CHARSET: iconv28# 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
30CONFIG="${HOME}/.split2flac"36CONFIG="${HOME}/.split2flac"
31TMPCUE="${HOME}/.split2flac_sheet.cue"37TMPCUE="${HOME}/.split2flac_sheet.cue"
32TMPPIC="${HOME}/.split2flac_cover.jpg"38TMPPIC="${HOME}/.split2flac_cover.jpg"
@@ -139,7 +145,7 @@ while [ "$1" ]; do · 106 unmodified lines
139 exit 1145 exit 1
140 elif [ ! -r "$1" ]; then146 elif [ ! -r "$1" ]; then
141 emsg "Unable to read $1"147 emsg "Unable to read $1"
142 exit 1148 exit 2
143 else149 else
144 INPATH="$1"150 INPATH="$1"
145 fi;;151 fi;;
@@ -520,28 +526,28 @@ split_collection () { · 374 unmodified lines
520 echo526 echo
521 done527 done
522 528
523 return ${NUM_FAILED}
524}
525
526# searches for files in a directory and splits them
527split_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 ]; then529 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 fi536 fi
537
538 return 0
539}
540
541# searches for files in a directory and splits them
542split_dir () {
543 rm -f "${FAILED}"
544 find "$1" -iname '*.flac' -o -iname '*.ape' -o -iname '*.wv' | split_collection
539}545}
540 546
541if [ -d "${INPATH}" ]; then547if [ -d "${INPATH}" ]; then
542 if [ ! -x "${INPATH}" ]; then548 if [ ! -x "${INPATH}" ]; then
543 emsg "Directory \"${INPATH}\" is not accessible"549 emsg "Directory \"${INPATH}\" is not accessible"
544 exit 1550 exit 2
545 fi551 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 1558 exit 1
553fi559fi
554 560
561# return code of split_dir or split_file
562STATUS=$?
563
555$msg "\n${cP}Finished$cZ"564$msg "\n${cP}Finished$cZ"
565
566if [ ${STATUS} -ne 0 ]; then
567 exit 3
568fi

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t