bug-bash
[Top][All Lists]
Advanced

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

Re: printf "%q" and $'...'


From: Antonio Macchi
Subject: Re: printf "%q" and $'...'
Date: Wed, 25 Nov 2009 16:27:06 +0100
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)

When you run  read -d $'\x00'  what you're really doing is setting up
a bunch of C-strings in memory like this:

 +-+-+-+-+--+-
 |r|e|a|d|\0|
 +-+-+-+-+--+-

 +-+-+--+-
 |-|d|\0|
 +-+-+--+-

 +--+--+-
 |\0|\0|
 +--+--+-


WOW!

but...

$ printf one$'\x00'two\\n

+-+-+-+-+-+-+--+
|p|r|i|n|t|f|\0|
+-+-+-+-+-+-+--+

+-+-+-+--+-+-+-+--+--+
|o|n|e|\0|t|w|o|\n|\0|
+-+-+-+--+-+-+-+--+--+

so the output should be "one", and stop here!

but the real output is
onetwo

so, imho, there's something more...




imadev:~$ echo $'foo\0bar'
foo


sorry... I'm a little bit confusing... look

$ echo foo$'\0'bar
foobar






reply via email to

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