Re: builtin read stops at '\0'

2011-05-22 Thread Ole Tange
On Thu, May 19, 2011 at 03:23:55PM +0200, Rafael 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'. Use GNU Parallel: printf "ole\0tange\nfafael\0fourquet\n" | parallel --colsep '\0

Re: builtin read stops at '\0'

2011-05-19 Thread Greg Wooledge
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:~$

Re: builtin read stops at '\0'

2011-05-19 Thread Rafaël Fourquet
> > 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

Re: builtin read stops at '\0'

2011-05-19 Thread Greg Wooledge
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

Re: builtin read stops at '\0'

2011-05-19 Thread Rafaël Fourquet
> > > 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

Re: builtin read stops at '\0'

2011-05-19 Thread Greg Wooledge
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

builtin read stops at '\0'

2011-05-18 Thread Rafaël Fourquet
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/l