I think this shows the bug in a simpler way:
$ echo A > foo ; echo B > bar
$ echo ./{foo,bar}
./foo ./bar
$ cat <(echo ./{foo,bar})
./foo
./bar
Why does process substitution add the newline? It doesn't happen when the
files are listed separately, not using the {} syntax:
$ echo ./foo ./bar
./foo ./bar
$ cat <(echo ./foo ./bar)
./foo ./bar
Apparently, this bug was fixed in newer Bash. It's not that big of a deal
now that I know about it!
Mike
On Tue, 25 Mar 2014, Mike Miller wrote:
> Here's a bug I just discovered in GNU Bash. It's in this version:
>
> GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
> Copyright (C) 2005 Free Software Foundation, Inc.
>
> I make two files of one character each:
>
> $ echo A > foo
> $ echo B > bar
>
>
> This works as expected:
>
> $ echo -e 'C\nD' | paste <(cat foo bar) -
> A C
> B D
>
>
> This should do the same thing but it fails:
>
> $ echo -e 'C\nD' | paste <(cat ./{foo,bar}) -
> A B C
> D
>
> That's pretty bad! I have to be careful. Strangely, it's all about the use
> of "<()" for process substitution because this behaves normally:
>
> $ cat ./{foo,bar}
> A
> B
>
> This newer version of Bash does not have the same problem:
>
> GNU bash, version 4.0.33(1)-release (x86_64-pc-linux-gnu)
> Copyright (C) 2009 Free Software Foundation, Inc.
>
>
> Unfortunately, our rocks cluster built on CentOS is using the old version of
> Bash. Another University machine is running this old version and it also has
> the bug:
>
> GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)
> Copyright (C) 2002 Free Software Foundation, Inc.
>
>
> So my own boxes are OK, all using Bash 4 and Ubuntu, but I can't upgrade Bash
> on these other machines without requesting help.
>
> Mike
>