[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Some byte combinations affect UTF-8 string reading
From: |
Grisha Levit |
Subject: |
Re: Some byte combinations affect UTF-8 string reading |
Date: |
Mon, 25 Feb 2019 18:02:58 -0500 |
On Mon, Feb 25, 2019 at 4:01 PM L A Walsh <bash@tlinx.org> wrote:
> ntc() { while IFS='' read -r input; do printf "$input;" ; done ; }
> printf $'\xc2\00\00\00\00'|ntc|hexdump -C
>
> both result in no output.
a) If you actually want the null bytes to be piped, the \0 has to be
interpreted by printf. Using $'' quoting means that \0 and anything
after is already lost after expansion. i.e. printf 'x\0y' and printf
$'x\0y' are not the same.
b) `read' will not have an exit status of 0 if it doesn't see the
delimeter so the condition in the while loop will never be satisfied
if you don't use -d ''