[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: echo $'\0' >a does not write the nul byte
From: |
Martin Schulte |
Subject: |
Re: echo $'\0' >a does not write the nul byte |
Date: |
Sun, 17 Jan 2021 21:56:57 +0100 |
Hello Hans, hello Eduardo!
> On Sun, Jan 17, 2021 at 12:05 PM <hans@artax.karlin.mff.cuni.cz> wrote:
> > (...)
> > The nul byte is not echoed by $'\0'.
>
> This is expected. Bash uses NUL-byte terminated character sequences to
> store strings, so it can't actually store NUL bytes themselves.
To be exact, this is already caused by a Unix Kernel - strings passed by the
exex* system calls are null terminated, too. As it is the default in the C
programming language. Thus you can't pass a null byte in an argument when
invoking a program.
Best regards
Martin