bug-bash
[Top][All Lists]
Advanced

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

Bash 5.2: broken built-in printf for float numbers


From: Thomas Dreibholz
Subject: Bash 5.2: broken built-in printf for float numbers
Date: Thu, 7 Nov 2024 10:16:46 +0100
User-agent: Mozilla Thunderbird

Hi,

Bash 5.2 has a broken built-in printf for float numbers.

Example: printf "%5.1f" 1024 should print "1024.0" (with standard locale LC_ALL=C.UTF-8)

Testing the Bash shell in different versions of recent Debian and Ubuntu setups, the output is wrong. Bug tracker for Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1081424 .Depending on the Debian/Ubuntu patch version of Bash, the output made by Bash is either complete garbage (random), or "nan" or "-0.0". The output of the external command /usr/bin/printf is always correct.

The attached small Bash script runs Docker with different Debian and Ubuntu containers, generating test output with version information. The generated output of ./bash-bug-test1 | tee bash-bug-test1.log is attached as well.

--
Best regards / Mit freundlichen Grüßen / Med vennlig hilsen

=======================================================================
 Thomas Dreibholz

 Simula@OsloMet -- Simula Metropolitan Centre for Digital Engineering
 Centre for Resilient Networks and Applications
 Pilestredet 52
 0167 Oslo, Norway
-----------------------------------------------------------------------
 E-Mail:     dreibh@simula.no
 Homepage:   http://simula.no/people/dreibh
=======================================================================

Attachment: bash-bug-test1.log
Description: Text Data

Attachment: bash-bug-test1
Description: Text document

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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