On 12/3/25 6:15 AM, Léa Gris wrote:
Le 03/12/2025 à 11:55, Oğuz écrivait :
On Wednesday, December 3, 2025, Léa Gris <[email protected]
<mailto:[email protected]>> wrote:
TMOUT=$(bc -l <<<'4*a(1)') bash -c 'read -rp "TMOUT=$TMOUT: ";
printf "TMOUT=%f\\n" "$TMOUT"'
TMOUT=3.14159265358979323844: bash: ligne 1 : printf:
3.14159265358979323844: nombre non valable
TMOUT=3,000000
Most command line tools outright ignore the user locale these days. I'm
happy with what bash gets right and don't mind the rest
Ok then why does Bash parses the string value into float for the TMOUT
variable as if LC_NUMERIC=C but not the string value into float for printf?
(It's not really a float -- it's seconds and microseconds separated by a
`.').
A language's grammar shall not be locale dependant.
Sorry that POSIX does not agree with you.
Bash parsing of the TMOUT variable using a decimal point is proof that Bash
already has support for parsing string to float with a consistent grammar
of decimal point.
A bad assumption results in an invalid conclusion.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/