diff options
author | Martin Roth <gaumless@gmail.com> | 2022-12-08 19:04:02 -0700 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-12-13 14:34:59 +0000 |
commit | 0110e1abe0ba8e723aa21e8e8fdbc4a27294a6b7 (patch) | |
tree | 5e71deab5e9ad2954e7d43b3c0d0e1b17338e2bf /util | |
parent | 4e37a8dad27476873222eb0f9b6730f1d4e5a7e1 (diff) |
util/genbuild_h: Update printf %d to %s for sh compatability
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 <gaumless@gmail.com>
Change-Id: I97b6aa74d74379f6bdc1f0fceecc8002cc36ca09
Reviewed-on: https://review.coreboot.org/c/coreboot/+/70478
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util')
-rwxr-xr-x | util/genbuild_h/genbuild_h.sh | 16 |
1 files 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" |