Omitting this is a Bashism, but one apparently permitted by Dash.
nlog=0
for i in "$logdir/$tag".*; do
if [ ! -f "$i" ]; then continue; fi
nlog=0
for i in "$logdir/$tag".*; do
if [ ! -f "$i" ]; then continue; fi
done
## If there are too many, go through and delete some early ones.
if [ $nlog -gt $maxlog ]; then
done
## If there are too many, go through and delete some early ones.
if [ $nlog -gt $maxlog ]; then
+ n=$(( $nlog - $maxlog ))
for i in "$logdir/$tag".*; do
if [ ! -f "$i" ]; then continue; fi
rm -f "$i"
for i in "$logdir/$tag".*; do
if [ ! -f "$i" ]; then continue; fi
rm -f "$i"
if [ $n -eq 0 ]; then break; fi
done
fi
if [ $n -eq 0 ]; then break; fi
done
fi