printf(1) %c doesn't work as expected, instead like %.1s.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
coreutils (Ubuntu) |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
Binary package hint: coreutils
Ubuntu 7.10, coreutils 5.97-5.3ubuntu3.
coreutils' printf(1) and bash(1)'s built-in printf don't handle `%c'
in the expected way. Instead, it treats it as `%.1s'.
$ type printf
printf is a shell builtin
$ /usr/bin/printf %c 65
6$
$ printf %c 65
6$
$ /usr/bin/printf %.1s 65
6$
$ awk 'BEGIN {printf("%c", 65)}' </dev/null
A$
$
C, awk, Python, Perl, etc., all work as expected. As it stands, there's
no easy way of turning $foo containing "65" into "A". printf(1) does
accept
$ printf \\x41
A$
$
but that's not the same thing.
As with %d, printf(1) should turn the string argument "65" into an
integer before passing to printf(3).
Changed in coreutils: | |
importance: | Undecided → Wishlist |
I am able to confirm this on Intrepid and Hardy
gnomefreak@ Development: ~$ type printf Development: ~$ /usr/bin/printf %c 65 Development: ~$ printf %c 65 Development: ~$ Development: ~$
printf is a shell builtin
gnomefreak@
6gnomefreak@
6gnomefreak@
awk 'BEGIN {printf("%c", 65)}' </dev/null
Agnomefreak@
gnomefreak@ Development: ~$ printf \\x41 Development: ~$
Agnomefreak@