libraries, autospec: refactoring library loading to fix some issues

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-12-01 22:50:46 +01:00
parent 868c8b882a
commit 40a6110422
4 changed files with 20 additions and 21 deletions

View File

@ -20,11 +20,10 @@
me=(${0##*/} "@version@" "@date@")
if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then
. /etc/sysconfig/i18n
[ "$LANG" ] && export LANG
fi
TEXTDOMAIN="@package@"; export TEXTDOMAIN
[ -r @libdir@/libtranslate.lib ] ||
{ echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2
exit 1; }
. @libdir@/libtranslate.lib
# default values
let "pck_update = 0"

View File

@ -14,12 +14,10 @@ libmsgmng.lib: "$"library not found"": @libdir@/libtranslate.lib" 1>&2
exit 1; }
. @libdir@/libtranslate.lib
notify.debug $"loading"": \`libmsgmng.lib'..."
# notify family of message handling functions:
# - notify.debug
# - notify.warning
# - notify.error
# - notify.debug
# - notify.note
# args:
# $1 : message to print
@ -31,6 +29,13 @@ notify.debug $"loading"": \`libmsgmng.lib'..."
notify_def_msg="<"$"no message"">"
function notify.debug() {
[ ${verbose:-0} -gt 1 ] || return
echo -e "${WARN}DEBUG${NORM}: ${1:-$notify_def_msg}" 1>&2
}
notify.debug $"loading"": \`libmsgmng.lib'..."
function notify.warning() {
echo -e "${WARN}WARNING${NORM}: ${1:-$notify_def_msg}" 1>&2
}
@ -40,11 +45,6 @@ function notify.error() {
${EXIT_FUNC:-"exit"} 1
}
function notify.debug() {
[ ${verbose:-0} -gt 1 ] || return
echo -e "${WARN}DEBUG${NORM}: ${1:-$notify_def_msg}" 1>&2
}
function notify.note() {
[ ${verbose:-0} -ge 0 ] || return
echo -e "${1:-$notify_def_msg}"

View File

@ -8,18 +8,18 @@ libtest_is_loaded=1
[ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 3 ] &&
{ echo $"this script requires bash version 3 or better" >&2 && exit 1; }
[ -r @libdir@/libmsgmng.lib ] ||
{ echo "\
libtest.lib: "$"library not found"": @libdir@/libmsgmng.lib" 1>&2
exit 1; }
. @libdir@/libmsgmng.lib
[ -r @libdir@/libtranslate.lib ] ||
{ echo "\
libtest.lib: "$"library not found"": @libdir@/libtranslate.lib" 1>&2
exit 1; }
. @libdir@/libtranslate.lib
[ -r @libdir@/libmsgmng.lib ] ||
{ echo "\
libtest.lib: "$"library not found"": @libdir@/libmsgmng.lib" 1>&2
exit 1; }
. @libdir@/libmsgmng.lib
notify.debug $"loading"": \`libtest.lib'..."
[ -n "$testdir" ] ||

View File

@ -3,12 +3,12 @@
# Copyright (C) 2012 Davide Madrisan <davide.madrisan@gmail.com>
[ "$libtranslate_is_loaded" = 1 ] || {
libtest_is_loaded=1
libtranslate_is_loaded=1
[ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 2 ] &&
{ echo $"this script requires bash version 2 or better" >&2 && exit 1; }
notify.debug $"loading"": \`libtranslate.lib'..."
# do not load any other library to avoid loops
if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then
. /etc/sysconfig/i18n