From d3e0b3a19289ff16a2ce040fb20c74f5387f6dcb Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Mon, 18 Nov 2024 17:56:58 +0900 Subject: [PATCH] lib/command_duration: avoid relying on a specific locale --- lib/command_duration.bash | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/command_duration.bash b/lib/command_duration.bash index 352ef0f01a..850c67649e 100644 --- a/lib/command_duration.bash +++ b/lib/command_duration.bash @@ -5,8 +5,12 @@ # Get shell duration in decimal format regardless of runtime locale. # Notice: This function runs as a sub-shell - notice '(' vs '{'. function _shell_duration_en() ( - # DFARREL You would think LC_NUMERIC would do it, but not working in my local - LC_ALL='en_US.UTF-8' + # DFARREL You would think LC_NUMERIC would do it, but not working in my local. + # Note: LC_ALL='en_US.UTF-8' has been used to enforce the decimal point to be + # a period, but the specific locale 'en_US.UTF-8' is not ensured to exist in + # the system. One should instead use the locale 'C', which is ensured by the + # C and POSIX standards. + local LC_ALL=C printf "%s" "${EPOCHREALTIME:-$SECONDS}" )