Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: lea.gris@noiraude.net Newsgroups: gnu.bash.bug Subject: built-in printf %f parameter format depend on LC_NUMERIC Date: Tue, 09 Jul 2019 17:26:24 +0200 Lines: 43 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org X-Trace: usenet.stanford.edu 1562689035 32170 209.51.188.17 (9 Jul 2019 16:17:15 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=noiraude.net; s=noiraude; h=Date:Message-Id:Subject:To:From:Sender:Reply-To :Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=zEDPSTo8Cpmd2LoQMU2opQy0epCAG198wOD5UtUzZ08=; b=gW7lGnV0KKJmtSD6Al8YTlSdKM g+XjRBszuZth6sKgdJVDqDo93JpH67YzBspR4Tr11FvBCKDTVnKbEt5XTQnj+R35k5K4OEF4jGB3o I/obBKpkF3kKSbh6+p+/Du6XeNtedOi7AoVkuK49ZFY0U9NVYcthhLiI9YY5IFplf/SHPklLhdP6s cYjNQzZ/gSomJAFOTUcjVfwVMztF3NyH0iLrmewt4vpcrfHwIXY+DjZrO3uSHQSOIKSrpRqVXZtEA FKK/19Ib+jEJsoPuBt7dxwLNHsRo7JViAWQVUFaXlZsrpH/0+wCrzQNyiUCXSksCfYHPAAVsTaiFh c5jh74Ow==; X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:910:10c6:1::1 X-Mailman-Approved-At: Tue, 09 Jul 2019 12:17:12 -0400 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: Xref: csiph.com gnu.bash.bug:15100 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