X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=sh-lib;h=c9fa8d02924a44d5343c47075a6ea5b6adaeba2c;hb=refs%2Fheads%2Ft%2Fgrml-core;hp=15f15ff0aaa2f58b4697f906faefc454c42d216c;hpb=428ec94ebacd86503805752394bcbff515a0b042;p=grml-shlib.git diff --git a/sh-lib b/sh-lib index 15f15ff..c9fa8d0 100644 --- a/sh-lib +++ b/sh-lib @@ -6,6 +6,8 @@ # License: This file is licensed under the GPL v2. ################################################################################ +. /usr/lib/grml/core.sh + # VARIABLES {{{ VERBOSE__=0 VERBOSE_TMP__=0 @@ -25,8 +27,6 @@ EXIT_FUNCTION__="_syslog" # function to call upon die (can be set by user) SYSLOG__="YES" -CMD_LINE__="" # /proc/cmdline - LANG__="$LANG" LC_ALL__="$LC_ALL" LANGUAGE__="$LANGUAGE" @@ -69,7 +69,7 @@ vprint() local type_="$2" local message_="$3" - if [ $VERBOSE__ -ge $level_ -a -n "$message_" ]; then + if [ "$VERBOSE__" -ge "$level_" -a -n "$message_" ]; then echo -n "$type_" >&2 echo "$message_" >&2 fi @@ -285,8 +285,8 @@ checkId() local user_id_='' - user_id_=`id -u` - if [ $user_id_ != "$to_check_" ]; then + user_id_=$(id -u) + if [ "$user_id_" != "$to_check_" ]; then if [ -z "$message_" ]; then $error_function_ "UID \"$user_id_\" is not \"$to_check_\"" 77 else @@ -411,20 +411,14 @@ stringInString() # get value for bootparam given as first param getBootParam() { - local param_to_search_="$1" - local result_='' - - stringInString " $param_to_search_=" "$CMD_LINE__" || return 1 - result_="${CMD_LINE__##*$param_to_search_=}" - result_="${result_%%[ ]*}" - echo "$result_" - return 0 + getbootparam $1 + return "$?" } # Check boot commandline for specified option checkBootParam() { - stringInString " $1" "$CMD_LINE__" + checkbootparam $1 return "$?" } # }}} @@ -715,22 +709,14 @@ _checkExecutables() _checkExecutables -_checkBootParam() -{ - local path_="/proc/cmdline" - if [ -e "$path_" ]; then - CMD_LINE__=`execute "cat $path_" warnLog` - return 0 - fi - warnLog "$path_ does not exist, thus sh-lib may not work reliable!" - return 1 -} -_checkBootParam - - _setDebugLevel() { - local debug_="${DEBUG:-0}" + # accept only integer as arguments + if echo "$DEBUG" | grep -E -q '^[0-9]+$' ; then + local debug_="${DEBUG:-0}" + else + local debug_="0" + fi VERBOSE__="$debug_" } _setDebugLevel