c=$cbase/$service # c for command file path base
-glob="$c[0-9]*"
+glob="${c}[0-9]*"
arr=($glob); file="${arr[0]}"; [[ $glob != "$file" ]] || file=
[[ -d $cbase ]] || mkdir -p $cbase
if (( code )); then
send_mail=false
if [[ $file ]]; then
- i=${file#$c}
+ i=${file#"$c"}
if (( i < errors )); then
new_file=$c$((i+1))
mv $file $new_file
From: $USER@$(hostname -f)
Subject: $HOSTNAME: $service exit code: $code
-$(journalctl -u $service.service --after-cursor=$(<$file))
+$(journalctl -u $service.service --after-cursor="$(<$file)")
EOF
fi
else