From 0110e1abe0ba8e723aa21e8e8fdbc4a27294a6b7 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Thu, 8 Dec 2022 19:04:02 -0700 Subject: [PATCH] util/genbuild_h: Update printf %d to %s for sh compatability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When printing a date, genbuild_h is printing it as two digits, using a leading zero if the value is below 10. The shells like bash, dash, etc don't fully import the numbers 08 and 09 when using the printf conversion specifier %d. They apparently interpret the numbers as octal and only import the leading 0, dropping the 8 or 9. This isn't an issue for 01 to 07, because those are valid octal numbers, so %d prints them without an issue. Because 08 and 09 are not valid octal, various shells return different errors: Example shell returns for 'printf "%d" 08': bash: printf: 08: invalid octal number dash: printf: 08: not completely converted fish: 008: value not completely converted yash: printf: `08' is not a valid integer sash: printf: 08: not completely converted To prevent this, just print all of the values as strings. zsh just seems to ignore the possibility of the value being octal and prints the value as a single digit 0-9. Signed-off-by: Martin Roth Change-Id: I97b6aa74d74379f6bdc1f0fceecc8002cc36ca09 Reviewed-on: https://review.coreboot.org/c/coreboot/+/70478 Reviewed-by: Kyösti Mälkki Reviewed-by: Arthur Heymans Reviewed-by: Fred Reitberger Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) --- util/genbuild_h/genbuild_h.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/util/genbuild_h/genbuild_h.sh b/util/genbuild_h/genbuild_h.sh index 9245e8da6a..ae21d6c478 100755 --- a/util/genbuild_h/genbuild_h.sh +++ b/util/genbuild_h/genbuild_h.sh @@ -80,16 +80,16 @@ printf "#define COREBOOT_VERSION_TIMESTAMP %s\n" "${DATE}" printf "#define COREBOOT_ORIGIN_GIT_REVISION \"%s\"\n" "${GITREV}" printf "#define COREBOOT_EXTRA_VERSION \"%s\"\n" "${COREBOOT_EXTRA_VERSION}" -printf "#define COREBOOT_MAJOR_VERSION %d\n" "${MAJOR_VER}" -printf "#define COREBOOT_MINOR_VERSION %d\n" "${MINOR_VER}" +printf "#define COREBOOT_MAJOR_VERSION %s\n" "${MAJOR_VER}" +printf "#define COREBOOT_MINOR_VERSION %s\n" "${MINOR_VER}" printf "#define COREBOOT_BUILD \"%s\"\n" "$(our_date "${DATE}" "+%a %b %d %H:%M:%S %Z %Y")" -printf "#define COREBOOT_BUILD_YEAR_BCD 0x%d\n" "$(our_date "${DATE}" "+%y")" -printf "#define COREBOOT_BUILD_MONTH_BCD 0x%d\n" "$(our_date "${DATE}" "+%m")" -printf "#define COREBOOT_BUILD_DAY_BCD 0x%d\n" "$(our_date "${DATE}" "+%d")" -printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x%d\n" "$(our_date "${DATE}" "+%w")" -printf "#define COREBOOT_BUILD_EPOCH \"%d\"\n" "$(our_date "${DATE}" "+%s")" +printf "#define COREBOOT_BUILD_YEAR_BCD 0x%s\n" "$(our_date "${DATE}" "+%y")" +printf "#define COREBOOT_BUILD_MONTH_BCD 0x%s\n" "$(our_date "${DATE}" "+%m")" +printf "#define COREBOOT_BUILD_DAY_BCD 0x%s\n" "$(our_date "${DATE}" "+%d")" +printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x%s\n" "$(our_date "${DATE}" "+%w")" +printf "#define COREBOOT_BUILD_EPOCH \"%s\"\n" "$(our_date "${DATE}" "+%s")" printf "#define COREBOOT_DMI_DATE \"%s\"\n" "$(our_date "${DATE}" "+%m/%d/%Y")" printf "\n" printf "#define COREBOOT_COMPILE_TIME \"%s\"\n" "$(our_date "${DATE}" "+%T")" -printf "#define ASL_VERSION 0x%d\n" "${IASLVERSION}" +printf "#define ASL_VERSION 0x%s\n" "${IASLVERSION}" printf "#endif\n"