change-time.sh: Fix input of 08 and 09

printf was interpreting these as invalid octal numbers, they're
decimal.

Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
This commit is contained in:
Jonathon Hall 2024-08-06 12:43:20 -04:00
parent 05ce2cd0a6
commit 3a0df1bd4b
No known key found for this signature in database
GPG Key ID: 1E9C3CA91AE25114

View File

@ -25,8 +25,11 @@ get_date () {
echo
done
# Pad with zeroes to length of maximum value
value="$(printf "%0${#max}u" "$value")"
# Pad with zeroes to length of maximum value.
# The "$((10#$value))" is needed to handle 08 and 09 correctly, which printf
# would otherwise interpret as octal. This effectively strips the leading
# zero by evaluating an arithmetic expression with the base set to 10.
value="$(printf "%0${#max}u" "$((10#$value))")"
}
enter_time_and_change()