Control: tags -1 moreinfo
On Fri, 22 Dec 2023 15:12:12 +0100 Francesco =?utf-8?Q?Potort=C3=AC?=
<poto...@isti.cnr.it> wrote:
Package: bash
Version: 5.2.21-2
Severity: normal
X-Debbugs-Cc: none, Francesco Potortì <poto...@isti.cnr.it>
$ bash --version
GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ echo $((10#08))
8
pot@pot:~$ printf %d\\n 10#08
bash: printf: 10#08: invalid number
10
This is clearly a bug: printf should print no error, and just print 8 followed
by newline.
The rules that apply to printf arguments are not the same rules that
apply to $(( )). Here "10#08" is a plain string that is not interpreted
at all by bash nor printf. Only inside $(( )) and a few other cases,
"10#08" will be interpreted as the representation of a number in base 10
(this is a bashism, other shells do not do that).
From ARITHMETIC EVALUATION in bash(1):
The shell allows arithmetic expressions to be evaluated, under
certain circumstances (see the let and declare builtin commands, the
(( compound command, and Arithmetic Expansion).>
[...]
Integer constants follow the C language definition, without suffixes>
or character constants. Constants with a leading 0 are
interpreted as octal numbers. A leading 0x or 0X denotes
hexadecimal. Otherwise, numbers take the form [base#]n, where the
optional base is a decimal number between 2 and 64 representing
the arithmetic base, and n is a number in that base. If base# is
omitted, then base 10 is used.
However, this only happens on one of my two boxes with Debian
testing. The other one does not exhibit the bug, and printf just
prints 8 followed by newline.
That's interesting. What version of bash is installed in the other boxes?
Regards,
--
Gioele Barabucci