coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

printf: Should allow leading spaces when parsing numbers

Open drinkcat opened this issue 7 months ago • 1 comments

We should allow leading spaces when parsing numbers:

$ printf "%f\n" ' -0x1'
-1.000000
$ ./coreutils-main printf "%f\n" ' -0x1'
printf: '\ -0x1': expected a numeric value
0.000000

(seq parser currently does this right)

But not trailing spaces:

$ printf "%f\n" '-0x1 '
bash: printf: -0x1 : invalid number
-1.000000
$ ./coreutils-main printf "%f\n" '-0x1 '
printf: '-0x1\ ': value not completely converted
-1.000000

drinkcat avatar Mar 20 '25 10:03 drinkcat