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