bug-bash
[Top][All Lists]
Advanced

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

Re: echo $'\0' >a does not write the nul byte


From: Chet Ramey
Subject: Re: echo $'\0' >a does not write the nul byte
Date: Sun, 17 Jan 2021 16:02:51 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

On 1/17/21 3:05 PM, hans@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 lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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