diff --git a/atom b/atom index 63271e9..d7dcd5c 100755 --- a/atom +++ b/atom @@ -1,15 +1,17 @@ #!/usr/bin/env bash +declare -r \ + DOCDIR=%DOCDIR% \ + LIBDIR=%LIBDIR% \ + SHAREDIR=%SHAREDIR% +declare -r \ + exampleconf=$DOCDIR/example.cfg \ + schema=$SHAREDIR/schema.sql \ + \ + oldIFS="$IFS" + ## Define exit codes -# General config errors [10-19] -ELOAD=10 -EINTERVAL=11 -ENOCFG=19 -# Source cofig errors [20-29] -# Destination config errors [30-49] -EFORMAT=30 -ECHANNEL=31 -EFMTINVPARM=49 +source "$SHAREDIR"/errorcodes # config structures declare -A \ @@ -36,21 +38,11 @@ declare -A \ exit $EBASHVERS } -declare -r \ - DOCDIR=%DOCDIR% \ - LIBDIR=%LIBDIR% \ - SHAREDIR=%SHAREDIR% -declare -r \ - exampleconf=$DOCDIR/example.cfg \ - schema=$SHAREDIR/schema.sql \ - \ - oldIFS="$IFS" - LC_ALL=C shopt -s extglob -source $SHAREDIR/id3genres +source "$SHAREDIR"/id3genres for function in "$LIBDIR"/*/* do @@ -125,12 +117,12 @@ do :) echo "-$OPTARG requires an argument" help - exit 127 + exit $EINVARG ;; *) echo "Unrecognized option: -$OPTARG" help - exit 127 + exit $EINVARG ;; esac done diff --git a/lib/database/checkVersion b/lib/database/checkVersion index 33ac892..71f850e 100644 --- a/lib/database/checkVersion +++ b/lib/database/checkVersion @@ -18,7 +18,7 @@ checkDatabaseVersion() { echo "Database schema version $dbversion is higher than that of this version of AtOM ($currentdbversion). Bailing out." >&2 - exit 1 + exit $EDBVERSION fi else Insert atom 1 <<<"version $currentdbversion" diff --git a/lib/workers/master b/lib/workers/master index d9d8097..0ef64e8 100644 --- a/lib/workers/master +++ b/lib/workers/master @@ -220,7 +220,7 @@ master() { echo "Waiting for children to come back home..." wait echo $'\nGood luck!' - exit 1 + exit $ETASKLEFT elif (( ready == 0 )) then sleep 0.1 diff --git a/share/errorcodes b/share/errorcodes new file mode 100644 index 0000000..8856a0c --- /dev/null +++ b/share/errorcodes @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +## Define exit codes +# General config errors [10-19] +EDBVERSION=10 +ELOAD=11 +EINTERVAL=12 +ELOAD=13 +EIONICE=14 +ENOCFG=19 +# Source cofig errors [20-29] +# Destination config errors [30-49] +EFORMAT=30 +ECHANNEL=31 +EQUALITY=32 +EMAXBPS=33 +EINVDEST=34 +EFMTINVPARM=49 +# Tasks +ETASKLEFT=50 +# Sanity +ESANITY=60 +# Invalid arguments +EINVARG=127 diff --git a/toys/checkextensions b/toys/checkextensions index 485e2c9..6c8d874 100755 --- a/toys/checkextensions +++ b/toys/checkextensions @@ -8,6 +8,19 @@ EOWarn read -p "Press Enter to continue or Ctrl-C to abort" +declare -r \ + DOCDIR=%DOCDIR% \ + LIBDIR=%LIBDIR% \ + SHAREDIR=%SHAREDIR% +declare -r \ + exampleconf=$DOCDIR/example.cfg \ + schema=$SHAREDIR/schema.sql \ + \ + oldIFS="$IFS" + +## Define exit codes +source "$SHAREDIR"/errorcodes + # config structures declare -A \ destinationchannels \ @@ -30,16 +43,6 @@ declare -A \ exit $EBASHVERS } -declare -r \ - DOCDIR=%DOCDIR% \ - LIBDIR=%LIBDIR% \ - SHAREDIR=%SHAREDIR% -declare -r \ - exampleconf=$DOCDIR/example.cfg \ - schema=$SHAREDIR/schema.sql \ - \ - oldIFS="$IFS" - LC_ALL=C shopt -s extglob diff --git a/toys/checkgenre b/toys/checkgenre index d3b4f85..6fa5bcf 100755 --- a/toys/checkgenre +++ b/toys/checkgenre @@ -1,5 +1,18 @@ #!/usr/bin/env bash +declare -r \ + DOCDIR=%DOCDIR% \ + LIBDIR=%LIBDIR% \ + SHAREDIR=%SHAREDIR% +declare -r \ + exampleconf=$DOCDIR/example.cfg \ + schema=$SHAREDIR/schema.sql \ + \ + oldIFS="$IFS" + +## Define exit codes +source "$SHAREDIR"/errorcodes + # config structures declare -A \ destinationchannels \ @@ -22,16 +35,6 @@ declare -A \ exit $EBASHVERS } -declare -r \ - DOCDIR=%DOCDIR% \ - LIBDIR=%LIBDIR% \ - SHAREDIR=%SHAREDIR% -declare -r \ - exampleconf=$DOCDIR/example.cfg \ - schema=$SHAREDIR/schema.sql \ - \ - oldIFS="$IFS" - LC_ALL=C shopt -s extglob diff --git a/toys/checkmissing b/toys/checkmissing index f747f17..13215f0 100755 --- a/toys/checkmissing +++ b/toys/checkmissing @@ -1,5 +1,18 @@ #!/usr/bin/env bash +declare -r \ + DOCDIR=%DOCDIR% \ + LIBDIR=%LIBDIR% \ + SHAREDIR=%SHAREDIR% +declare -r \ + exampleconf=$DOCDIR/example.cfg \ + schema=$SHAREDIR/schema.sql \ + \ + oldIFS="$IFS" + +## Define exit codes +source "$SHAREDIR"/errorcodes + # config structures declare -A \ destinationchannels \ @@ -22,16 +35,6 @@ declare -A \ exit $EBASHVERS } -declare -r \ - DOCDIR=%DOCDIR% \ - LIBDIR=%LIBDIR% \ - SHAREDIR=%SHAREDIR% -declare -r \ - exampleconf=$DOCDIR/example.cfg \ - schema=$SHAREDIR/schema.sql \ - \ - oldIFS="$IFS" - LC_ALL=C shopt -s extglob diff --git a/toys/cleandestinations b/toys/cleandestinations index 10b9503..e45ef59 100755 --- a/toys/cleandestinations +++ b/toys/cleandestinations @@ -1,5 +1,18 @@ #!/usr/bin/env bash +declare -r \ + DOCDIR=%DOCDIR% \ + LIBDIR=%LIBDIR% \ + SHAREDIR=%SHAREDIR% +declare -r \ + exampleconf=$DOCDIR/example.cfg \ + schema=$SHAREDIR/schema.sql \ + \ + oldIFS="$IFS" + +## Define exit codes +source "$SHAREDIR"/errorcodes + # config structures declare -A \ destinationchannels \ @@ -22,16 +35,6 @@ declare -A \ exit $EBASHVERS } -declare -r \ - DOCDIR=%DOCDIR% \ - LIBDIR=%LIBDIR% \ - SHAREDIR=%SHAREDIR% -declare -r \ - exampleconf=$DOCDIR/example.cfg \ - schema=$SHAREDIR/schema.sql \ - \ - oldIFS="$IFS" - LC_ALL=C shopt -s extglob diff --git a/toys/createindex b/toys/createindex index 48a735f..d1a01dd 100755 --- a/toys/createindex +++ b/toys/createindex @@ -1,6 +1,17 @@ #!/usr/bin/env bash -#!/bin/bash +declare -r \ + DOCDIR=%DOCDIR% \ + LIBDIR=%LIBDIR% \ + SHAREDIR=%SHAREDIR% +declare -r \ + exampleconf=$DOCDIR/example.cfg \ + schema=$SHAREDIR/schema.sql \ + \ + oldIFS="$IFS" + +## Define exit codes +source "$SHAREDIR"/errorcodes # config structures declare -A \ @@ -24,16 +35,6 @@ declare -A \ exit $EBASHVERS } -declare -r \ - DOCDIR=%DOCDIR% \ - LIBDIR=%LIBDIR% \ - SHAREDIR=%SHAREDIR% -declare -r \ - exampleconf=$DOCDIR/example.cfg \ - schema=$SHAREDIR/schema.sql \ - \ - oldIFS="$IFS" - LC_ALL=C shopt -s extglob diff --git a/toys/lowquality b/toys/lowquality index 5bc291c..665b30d 100755 --- a/toys/lowquality +++ b/toys/lowquality @@ -1,5 +1,18 @@ #!/usr/bin/env bash +declare -r \ + DOCDIR=%DOCDIR% \ + LIBDIR=%LIBDIR% \ + SHAREDIR=%SHAREDIR% +declare -r \ + exampleconf=$DOCDIR/example.cfg \ + schema=$SHAREDIR/schema.sql \ + \ + oldIFS="$IFS" + +## Define exit codes +source "$SHAREDIR"/errorcodes + # config structures declare -A \ destinationchannels \ @@ -22,16 +35,6 @@ declare -A \ exit $EBASHVERS } -declare -r \ - DOCDIR=%DOCDIR% \ - LIBDIR=%LIBDIR% \ - SHAREDIR=%SHAREDIR% -declare -r \ - exampleconf=$DOCDIR/example.cfg \ - schema=$SHAREDIR/schema.sql \ - \ - oldIFS="$IFS" - LC_ALL=C shopt -s extglob diff --git a/toys/missingtags b/toys/missingtags index 9baa389..f523ff2 100755 --- a/toys/missingtags +++ b/toys/missingtags @@ -1,5 +1,18 @@ #!/usr/bin/env bash +declare -r \ + DOCDIR=%DOCDIR% \ + LIBDIR=%LIBDIR% \ + SHAREDIR=%SHAREDIR% +declare -r \ + exampleconf=$DOCDIR/example.cfg \ + schema=$SHAREDIR/schema.sql \ + \ + oldIFS="$IFS" + +## Define exit codes +source "$SHAREDIR"/errorcodes + # config structures declare -A \ destinationchannels \ @@ -23,16 +36,6 @@ declare -A \ exit $EBASHVERS } -declare -r \ - DOCDIR=%DOCDIR% \ - LIBDIR=%LIBDIR% \ - SHAREDIR=%SHAREDIR% -declare -r \ - exampleconf=$DOCDIR/example.cfg \ - schema=$SHAREDIR/schema.sql \ - \ - oldIFS="$IFS" - LC_ALL=C shopt -s extglob