Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15100 > unrolled thread

built-in printf %f parameter format depend on LC_NUMERIC

Started bylea.gris@noiraude.net
First post2019-07-09 17:26 +0200
Last post2019-07-09 17:26 +0200
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  built-in printf %f parameter format depend on LC_NUMERIC lea.gris@noiraude.net - 2019-07-09 17:26 +0200

#15100 — built-in printf %f parameter format depend on LC_NUMERIC

Fromlea.gris@noiraude.net
Date2019-07-09 17:26 +0200
Subjectbuilt-in printf %f parameter format depend on LC_NUMERIC
Message-ID<mailman.666.1562689035.2688.bug-bash@gnu.org>
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

Description:
        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.]

Repeat-By:
        Use of built-in printf:
        bash -c 'LC_NUMERIC=fr_FR.UTF-8 printf "%f\\n" "$(echo "scale=1;1/3" | bc)"'
        > 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" | bc)"'
        > 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

Fix:
	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 commands 
        like bc, it would help to handle floating-point numbers parameter format 
        consistently with the stand-alone printf command

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web