> during developing a new shell script; I detected an erroneous behaviour > of the printf command.
Thank you for your report. But I believe you are unaware that leading zeros indicate octal encoding. Neither 8 nor 9 are valid octal values. And of course 010 octal is 9 decimal and so on. > printf fails on hex conversion for 008 and 009 and gives wrong values > for higher numbers, if the digit to convert contains leading zeroes. > Without leading zeroes the conversion succeeds. > > echo $BASH_VERSION > 2.04.21(1)-release printf is both a shell built in and a standalone program. You are using the shell built in, thanks for including the shell version btw, which if actually had a bug would need to go to [EMAIL PROTECTED] :-) It is confusing, I know, but this list is for the standalone programs. In this case it does not matter at all so don't worry about it. It is just for future reference. > # printf "%02x\n" 008 > bash: printf: 008: invalid number > # printf "%02x\n" 009 > bash: printf: 009: invalid number > # printf "%02x\n" 010 > 08 > # printf "%02x\n" 011 > 09 And if you had used the external program you would have seen this. /usr/bin/printf "%02x\n" 09 /usr/bin/printf: 09: value not completely converted 00 Numbers with leading zeros indicate octal encoding. Numbers with leading 0x indicate hexadecimal encoding. You can't put leading zeros on there if you want them to be decimal. Bob _______________________________________________ Bug-sh-utils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-sh-utils
