Arithmetic compound has inconsistent return semantics
((expr)) has a trap that if expr is 0, the return value is 1.
This will trigger a failure with "set -e" and can be very confusing.
It is good defensive programming to avoid this with explicit assignment.
Signed-off-by: Guillaume Lambert <guillaume.lambert@orange.com>
Change-Id: I412bd8872560c90c28642ed5433eab9b2a29a5e8
for item in "${docs_interests[@]}"; do
if ! grep -q "$item" "docs/${file//.yaml/.rst}"; then
echo "$file:$item"
- (( undocumented_count++ ))
+ undocumented_count=$((undocumented_count+1))
fi
done
done
fi
# Retrieve the current uptime (in seconds)
-uptime=$(awk '{print $1}' /proc/uptime)
-# Convert to integer by truncating fractional part' and round up by one
-((uptime=${uptime%\.*}+1))
+# And Convert to integer by truncating fractional part' and round up by one
+uptime=$(awk '{print int($1 + 1)}' /proc/uptime)
# EC2 and OpenStack have simiar instace metadata APIs at this IP
# AWS docs: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
fi
echo "INFO sleeping for 30 seconds $cnt times"
sleep 30
- ((cnt+=1))
+ cnt=$((cnt+1))
if (( cnt >= 20 )); then
echo "INFO: Job has timed out"
exit 1