From: Stefan Bund Date: Sat, 7 Nov 2009 15:41:18 +0000 (+0100) Subject: Move library directory scan into 'load' function X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=ed858a3f8ff897e16e1ebf496bf41471f3211798;p=mapsector.git Move library directory scan into 'load' function --- diff --git a/mapsector b/mapsector index 9eb97c6..d8aaa24 100755 --- a/mapsector +++ b/mapsector @@ -5,6 +5,9 @@ mappers="" scanners="" version="unknown" +name="`basename "$0"`" + +unset LANG register_mapper() { @@ -18,7 +21,23 @@ register_scanner() load() { - for lib in `ls "$1"/[0-9][0-9]_*.sh | sort`; do + local X + local lib + + X="`dirname "$0"`" + if [ "`basename "$X"`" == "bin" ]; then # `" + libdir="`dirname "$X"`/share/$name" #`" + fi + if [ -z "$libdir" -o ! -d "$libdir" ]; then + libdir="$X/lib" + fi + + if [ ! -d "$libdir" ]; then + echo "! Library directory not found" 1>&2 + exit 1 + fi + + for lib in `ls "$libdir"/[0-9][0-9]_*.sh | sort`; do source $lib done } @@ -56,25 +75,9 @@ scan() ########################################################################### -unset LANG - -#### Find library directory and load library files - -name="`basename "$0"`" -X="`dirname "$0"`" -if [ "`basename "$X"`" == "bin" ]; then # `" - libdir="`dirname "$X"`/share/$name" #`" -fi -if [ -z "$libdir" -o ! -d "$libdir" ]; then - libdir="$X/lib" -fi - -if [ ! -d "$libdir" ]; then - echo "! Library directory not found" 1>&2 - exit 1 -fi +#### Load library modules -load "$libdir" +load #### Parse command line arguments