Le 06/06/2024 à 11:55, Koichi Murase écrivait :
Though, I see your point. It is inconvenient that we cannot pass the results of arithmetic evaluations to the `printf' builtin. This appears to be an issue of the printf builtin. I think the `printf' builtin should be extended to interpret both forms of the numbers, the locale-dependent formatted number and the floating-point literals.
Another way would be to expand string representation of floating-point numbers using the locale. Anyway, yes this POSIX restriction is pointless but causes troubles.
Anyway, writing locale agnostic Bash scripts requires some precautions (like setting LC_ALL=C), that too many developers tend to ignore; before running commands without output to parse.
Using LC_NUMERIC=C printf ... is an even less known precaution and I have already stumbled on a couple scripts that break because of this exact overlook.
-- Léa Gris