On Wed, May 18, 2011 at 02:10:39PM +0200, Rafaël Fourquet wrote:
> If a line containing the '\0' is read into a variable, the content
> of this variable does not contain the part after the '\0' character.
>
> Repeat-By:
> echo -e 'a\0b' | (read f; echo $f)
>
> The
>
>
> If you want to handle a stream of NUL-delimited strings in bash, the
> best approach is to use read -d '', thus:
>
> imadev:~$ printf '%s\0' one two three | while read -r -d '' s; do echo
> "<$s>"; done
>
>
>
>
> read -d '' means "stop at NUL, instead of stopping at newline".
>
Thanks for
On Thu, May 19, 2011 at 03:23:55PM +0200, Rafaël Fourquet wrote:
> I have a program which outputs groups of filenames. Each group is separated
> by a newline, and within each group,
> each name is separated by '\0'.
That seems backwards somehow... the "stronger" delimiter (NUL) is used
in the inne
>
> Here's what I'd do: just use tr to swap the delimiters.
>
> while read -d '' -r group; do
> mapfile -t files <<< "$group"
> ...
> done < <(tr '\n\0' '\0\n' < "yourfile")
>
> > I want to pipe each group to xargs -0.
>
> Not what I'd do.
>
Thanks!
But is there something wrong with xargs? or is
On Thu, May 19, 2011 at 04:30:40PM +0200, Rafaël Fourquet wrote:
> Do you mean, in your example, that e.g.
> ... do mapfile -t files <<< "$group" ; ls -1 "${files[@]}"; done ...
> is better than:
> ... do xargs -d '\n' ls -1 <<<"$group"; done ...
imadev:~$ group=$'foo\nbar\n"hi mom"\n'
imadev:~$
On 13 May 2011, at 20:07, DJ Mills wrote:
> A -0 option, or even an option to use a different field separator, would be
> an
> excellent feature for mapfile. Currently, of course, you can use:
>
> while IFS= read -rd '' file; do array+=("$file"); done
>
> mapfile is considerably faster, however
[adding bug-bash]
On 05/16/2011 07:23 PM, Wayne Pollock wrote:
> (While cleaning up the standard for case statement, consider that it is
> currently
> unspecified what should happen if an error occurs during the expansion of the
> patterns; as expansions may have side-effects, when an error occur