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
2727 # ART: ImageMagick
2828 # CHARSET: iconv
2929
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+
3036 CONFIG="${HOME}/.split2flac"
3137 TMPCUE="${HOME}/.split2flac_sheet.cue"
3238 TMPPIC="${HOME}/.split2flac_cover.jpg"
@@ -139,7 +145,7 @@ while [ "$1" ]; do · 106 unmodified lines
139145 exit 1
140146 elif [ ! -r "$1" ]; then
141147 emsg "Unable to read $1"
142− exit 1
148+ exit 2
143149 else
144150 INPATH="$1"
145151 fi;;
@@ -520,28 +526,28 @@ split_collection () { · 374 unmodified lines
520526 echo
521527 done
522528
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−
532529 if [ ${NUM_FAILED} -ne 0 ]; then
533530 emsg "${NUM_FAILED} file(s) failed to split (already splited?):"
534531 $msg "${cR}"
535532 sort "${FAILED}" -o "${FAILED}"
536533 cat "${FAILED}"
537534 emsg "\nThese files are also listed in ${FAILED}."
535+ return 1
538536 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
539545 }
540546
541547 if [ -d "${INPATH}" ]; then
542548 if [ ! -x "${INPATH}" ]; then
543549 emsg "Directory \"${INPATH}\" is not accessible"
544− exit 1
550+ exit 2
545551 fi
546552 $msg "${cG}Input dir :$cZ ${INPATH}$cZ\n"
547553 split_dir "${INPATH}"
@@ -552,4 +558,11 @@ else · 4 unmodified lines
552558 exit 1
553559 fi
554560
561+# return code of split_dir or split_file
562+STATUS=$?
563+
555564 $msg "\n${cP}Finished$cZ"
565+
566+if [ ${STATUS} -ne 0 ]; then
567+ exit 3
568+fi

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