You are not logged in.

#1 2020-04-02 01:52:45

joanbrugueram
Member
Registered: 2018-11-12
Posts: 21

[SOLVED] Obscure issue with process substitution since bash-5.0.016

I'm having a problem with a script that used to work, which I reduced to the following test case:

#!/bin/bash

function docat() {
	for x in 1 2 3 ; do true; done
	cat "$@"
}

for x in $(seq 25); do
	docat <(echo a) <(echo a) <(echo a) <(echo a) <(echo a) <(echo a)
done

Expected behaviour: A lot of lines with an "a" are printed

Actual behaviour: Some lines with an "a" are printed but a lot of prints fail with an error:

[...]
a
cat: /dev/fd/63: No such file or directory
cat: /dev/fd/62: No such file or directory
cat: /dev/fd/61: No such file or directory
cat: /dev/fd/60: No such file or directory
a
[...]

Now if you remove the apparently useless for loop in the first line of docat, this works as I would expect. It also works on zsh.

After some head banging I found that what makes the difference is the latest bash update on Arch Linux. In particular with the previous version of bash it worked, but with bash-5.0.016 it doesn't. The particular specific version that breaks this script is bash-5.0.015 and this is the patch that makes the difference: https://ftp.gnu.org/gnu/bash/bash-5.0-p … bash50-016

Can some bash expert illuminate whether the script was technically wrong but worked due to some bash implementation detail, or is this could actually a problem with bash? And if it's the former, what would be a sensible alternative?

Thanks.

Last edited by joanbrugueram (2020-04-02 02:47:24)

Offline

#2 2020-04-02 02:18:42

joanbrugueram
Member
Registered: 2018-11-12
Posts: 21

Re: [SOLVED] Obscure issue with process substitution since bash-5.0.016

I went ahead and posted this to the bug-bash mailing list, since that was probably the right place from the beginning. I also found a similar bug report there but I'm unable to verify whether it's actually the same bug.

Can't delete the post on Arch forum. Still, if someone knows something about this, tell me. I'll  [Solved] the post when I get a response from the mailing list.

Last edited by joanbrugueram (2020-04-02 02:19:13)

Offline

#3 2020-04-02 02:50:12

joanbrugueram
Member
Registered: 2018-11-12
Posts: 21

Re: [SOLVED] Obscure issue with process substitution since bash-5.0.016

Solved. This was actually a bug in bash and has already been fixed in the latest git ( https://git.savannah.gnu.org/cgit/bash.git?h=devel ).

Offline

Board footer

Powered by FluxBB