help-bash
[Top][All Lists]
Advanced

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

Re: Is there a way to not to ignore null in $()?


From: Eli Schwartz
Subject: Re: Is there a way to not to ignore null in $()?
Date: Mon, 11 May 2020 09:09:49 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 5/11/20 8:13 AM, Peng Yu wrote:
> $ x=$(awk -e 'BEGIN{print "a\000b" }')
> -bash: warning: command substitution: ignored null byte in input
> $ declare -p x
> declare -- x="ab"
> 
> I think that there is no way to avoid the above warning as no null
> character can be in a bash variable. But if I want to avoid using a
> temp file, then I have to have to save the output in a bash variable?
> 
> Is there a good way to save some binary data in memory in bash? Thanks.

The warning is literally telling you that you cannot store null bytes in
bash, and it is ignoring it.

The warning is relatively new, it exists to alert you to the fact that
before then, those null bytes were always ignored, but were ignored
silently.

Please rewrite your application in a real programming language, which
can store arbitrary data like null bytes.

Or use a temp file/pipe. Stop trying to ignore literally the only
solution because you don't like it. Why is it that essentially every one
of your posts to this list is "bash is telling me I am not permitted to
do XXX, is there a way to do it anyway"?

-- 
Eli Schwartz
Bug Wrangler and Trusted User

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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