From 40a6110422ad6c49581cd37cfffa8df7252530c5 Mon Sep 17 00:00:00 2001 From: Davide Madrisan Date: Sat, 1 Dec 2012 22:50:46 +0100 Subject: [PATCH] libraries, autospec: refactoring library loading to fix some issues Signed-off-by: Davide Madrisan --- autospec.in | 9 ++++----- lib/libmsgmng.lib.in | 16 ++++++++-------- lib/libtest.lib.in | 12 ++++++------ lib/libtranslate.lib.in | 4 ++-- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/autospec.in b/autospec.in index 0f0f5b9..d008da8 100644 --- a/autospec.in +++ b/autospec.in @@ -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" diff --git a/lib/libmsgmng.lib.in b/lib/libmsgmng.lib.in index 2e18290..73b9ba7 100644 --- a/lib/libmsgmng.lib.in +++ b/lib/libmsgmng.lib.in @@ -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}" diff --git a/lib/libtest.lib.in b/lib/libtest.lib.in index ca34e35..972ff04 100644 --- a/lib/libtest.lib.in +++ b/lib/libtest.lib.in @@ -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" ] || diff --git a/lib/libtranslate.lib.in b/lib/libtranslate.lib.in index 25e5748..74e7057 100644 --- a/lib/libtranslate.lib.in +++ b/lib/libtranslate.lib.in @@ -3,12 +3,12 @@ # Copyright (C) 2012 Davide Madrisan [ "$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