From 141791db924aa414af23cc62eac7c8fa52cf245a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lesimple?= Date: Fri, 15 Jan 2021 15:06:46 +0000 Subject: [PATCH] fix: scripts: (( )) returns 1 if evaluated to zero --- bin/cron/osh-lingering-sessions-reaper.sh | 4 ++-- bin/cron/osh-rotate-ttyrec.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/cron/osh-lingering-sessions-reaper.sh b/bin/cron/osh-lingering-sessions-reaper.sh index 98afa78..ef7e186 100755 --- a/bin/cron/osh-lingering-sessions-reaper.sh +++ b/bin/cron/osh-lingering-sessions-reaper.sh @@ -19,7 +19,7 @@ while read etimes pid tty do if [ "$tty" = "?" ] && [ "$etimes" -gt 86400 ]; then tokill="$tokill $pid" - (( nb++ )) + (( ++nb )) fi done < <(ps -C ttyrec -o etimes,pid,tty --no-header) if [ -n "$tokill" ]; then @@ -37,7 +37,7 @@ do if [ "$tty" = "?" ] && [ "$user" != "root" ] && [ "$etimes" -gt 86400 ]; then if [ "$(ps --no-header --ppid "$pid" | wc -l)" = 0 ]; then tokill="$tokill $pid" - (( nb++ )) + (( ++nb )) fi fi done < <(ps -C sshd --no-header -o etimes,pid,tty,user) diff --git a/bin/cron/osh-rotate-ttyrec.sh b/bin/cron/osh-rotate-ttyrec.sh index faa6a83..91985ea 100755 --- a/bin/cron/osh-rotate-ttyrec.sh +++ b/bin/cron/osh-rotate-ttyrec.sh @@ -19,7 +19,7 @@ if [ "$1" = "--big-only" ]; then do if echo "$size" | grep -qE '^[0-9]+$' && [ "$size" -gt 100000000 ]; then tokill="$tokill $pid" - (( nb++ )) + (( ++nb )) fi done < <(lsof -a -n -c ttyrec 2>/dev/null -- /home/ 2>/dev/null) if [ -n "$tokill" ]; then