From 809e4756936a6c1bf5c700778dca317cab8c351e Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Sun, 11 Jan 2015 20:33:25 +0200 Subject: [PATCH] Check for negative counter values --- func/main.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/func/main.sh b/func/main.sh index 60a7d2eb7..8d309f368 100644 --- a/func/main.sh +++ b/func/main.sh @@ -243,7 +243,7 @@ is_object_unsuspended() { spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'") fi if [ ! -z "$spnd" ]; then - echo "Error: $(basename $1) $3 is already suspended" + echo "Error: $(basename $1) $3 is suspended" log_event "$E_UNSUSPENDED" "$EVENT" exit $E_UNSUSPENDED fi @@ -357,6 +357,9 @@ decrease_user_value() { else new=$((old - factor)) fi + if [ "$new" -lt 0 ]; then + new=0 + fi sed -i "s/$key='$old'/$key='$new'/g" $conf }