Le 17/01/2021 à 22:02, Chet Ramey écrivait :
On 1/17/21 3:05 PM, h...@artax.karlin.mff.cuni.cz wrote:
Description:
Command
echo $'\0' |od -c
writes
0000000 \n
0000001
in contrast to
echo $'\1' |od -c
0000000 001 \n
0000002
The nul byte is not echoed by $'\0'.
Repeat-By:
echo $'\0' |od -c
echo $'\1' |od -c
Shell builtin commands obey the same argv conventions as any other Unix
program: arguments are null-terminated strings. That means that
echo $'\0'
echo ''
echo ""
are all equivalent, and none of them will output a null byte.
The only way to output a null byte with shell built-in is:
printf '\0'
or non portable: echo -ne '\0'
This is because `\0' is not a null byte or a nulll string but
interpreted internally to the command to print a null byte.
--
Léa Gris