From 3a0df1bd4b7b17b05a5b58a573787174c6038103 Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Tue, 6 Aug 2024 12:43:20 -0400 Subject: [PATCH] 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 --- initrd/bin/change-time.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/initrd/bin/change-time.sh b/initrd/bin/change-time.sh index 7f1de885..0fb505ce 100755 --- a/initrd/bin/change-time.sh +++ b/initrd/bin/change-time.sh @@ -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()