bug-bash
[Top][All Lists]
Advanced

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

Re: Questions to bash "read" builtin functionality (and supposed problem


From: Pierre Gaston
Subject: Re: Questions to bash "read" builtin functionality (and supposed problem with while).
Date: Fri, 18 Jan 2013 07:57:50 +0200

On Thu, Jan 17, 2013 at 4:24 PM, Linus Swälas <linus.swalas@gmail.com>wrote:

> I have a similar problem to report as Fiedler Roman regarding read and also
> another problem regarding while. Maybe the while case is intended behavior
> though. =)
> # It the below also a bug?
>
# while can't handle nulls, this doesn't work:
> # while read -d \x00 cfg
> # while this does work:
> # read -d \x00 test < <(find . -name some_file -print0) ; echo $test
>
>
\x00 doesn't mean anything special for bash  it's just an "x" followed by 2
zeros (echo, printf can interpret it and it has a special meaning inside
$'')
Even if it did, you cannot really pass the null byte as an argument, bash
uses null delimited string so the best you can do is to pass the empty
string:
read -d ''
The good thing is that it works to read null delimited input! you need a
bit more work to be fully safe though:
while IFS= read -rd ''; do ..... done < <(find ... -print0)

Pierre
PS: next time consider trimming your use case to avoid us avoid to search
for your problems.


reply via email to

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