On Mon, Aug 02, 2004 at 10:09:09AM +0100, Tavis Ormandy wrote:
[...]
> but with 0x00, %c accepts it and %b won't
> $ printf "%c" $'\x00' | hexdump -e '"%#04x\n"'
> 0000
This is seen by printf the same way as:
printf %c ''
You can't put a NUL character in a command argument, as command
arguments (as well as environment variables) are NUL terminated
strings.
You can see it with:
printf %s $'A\0B'
> $ printf "%b" \\x00 | hexdump -e '"%#04x\n"'
> $
>
> Repeat-By:
> printf "%b" \\x00 | hexdump -e '"%#04x\n"'
[...]
In that case, I agree that it could be seen as a bug or a
limitation as printf is given the "\x00" 4 chars string argument
which is valid.
All of zsh, ksh builtin printf and GNU or Solaris /bin/printf
output the NUL here.
--
Stephane