[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

built-in printf %f parameter format depend on LC_NUMERIC

From: lea . gris
Subject: built-in printf %f parameter format depend on LC_NUMERIC
Date: Tue, 09 Jul 2019 17:26:24 +0200

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-LQgi2O/bash-5.0=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall 
-Wno-parentheses -Wno-format-security
uname output: Linux meumeu 5.0.0-20-generic #21-Ubuntu SMP Mon Jun 24 09:32:09 
UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.0
Patch Level: 3
Release Status: release

        When formatting floating point numbers in Bash's built-in 
        printf with %s, the argument format depends on the LC_NUMERIC
        environment variable.
        If the LC_NUMERIC language defines a comma , as decimal 
        separator, the built-in printf will not be able to recognize 
        floating-point numbers using a decimal point . as it is when 
        using the result of bc

        [Detailed description of the problem, suggestion, or complaint.]

        Use of built-in printf:
        bash -c 'LC_NUMERIC=fr_FR.UTF-8 printf "%f\\n" "$(echo "scale=1;1/3" | 
        > bash: line 0: printf: .3: invalid number
        > 0,000000

        bash -c 'LC_NUMERIC=en_US.UTF-8 printf "%f\\n" "$(echo "scale=1;1/3" | 
        > 0.300000

        Use of stand-alone printf:
        bash -c 'LC_NUMERIC=fr_FR.UTF-8 env printf "%f\\n" "$(echo 
"scale=1;1/3" | bc)"'
        > 0,300000

        The behaviour diferrence with floats against the stand-alone printf need
        documenting at as many places as possible.
        To help operating with floating-point numbers provided by different 
        like bc, it would help to handle floating-point numbers parameter 
        consistently with the stand-alone printf command

reply via email to

[Prev in Thread] Current Thread [Next in Thread]