[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: builtin printf's `%b` won't expand null

From: Stephane Chazelas
Subject: Re: builtin printf's `%b` won't expand null
Date: Mon, 2 Aug 2004 11:11:43 +0100
User-agent: Mutt/1.5.6i

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

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]