X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=sh-lib;h=e87b9cb1074b4ccb66667a6d23a53708a40f9393;hb=adadf04d7f9276acdae103fc761a6a6f4e3b41f2;hp=15f15ff0aaa2f58b4697f906faefc454c42d216c;hpb=428ec94ebacd86503805752394bcbff515a0b042;p=grml-shlib.git diff --git a/sh-lib b/sh-lib index 15f15ff..e87b9cb 100644 --- a/sh-lib +++ b/sh-lib @@ -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 @@ -515,7 +515,11 @@ netGetNetmask() local ret_='' setCLang - nm_=`ifconfig "$iface_" | awk '/[Mm]ask/{FS="[: ]*"; $0=$0; print $8; exit}'` + if ifconfig "$iface_" | grep -qi 'Mask:' ; then # old ifconfig output: + nm_=$(ifconfig "$iface_" | awk '/[Mm]ask/{FS="[: ]*"; $0=$0; print $8; exit}') + else # new ifconfig output (net-tools >1.60-27): + nm_=$(ifconfig "$iface_" | awk '/netmask/{print $4}') + fi ret_=$? restoreLang if [ -z "$nm_" ]; then @@ -542,8 +546,7 @@ netGetIp() local ret_="" setCLang - #ip_=`ip addr list eth0 |mawk '/inet/{split($2,A,"/"); print A[1]}'` - ip_=`ifconfig "$iface_" | awk '/[Ii]net [Aa]ddr/{FS="[: ]*"; $0=$0; print $4; exit}'` + ip_=$(ip addr show dev "$iface_" | awk '/inet /{split($2,a,"/"); print a[1]}') ret_=$? restoreLang if [ -z "$ip_" ]; then @@ -727,10 +730,14 @@ _checkBootParam() } _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