Failed $(
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 uname output: Linux hatter 5.18.19_1 #1 SMP PREEMPT_DYNAMIC Thu Aug 25 14:36:55 UTC 2022 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 5.2 Patch Level: !PATCHLEVEL! Release Status: release Description: When 'set -e' is enabled, file-content substitutions of the form $(<...) cause an immediate exit even when the subsitution is in a conditional context such as the condition of an 'if' statement or the left operand of the '||' operator. I'm guessing this probably has something to do with the fork-suppression mentioned in the release notes for bash 5.2, since the problem seems to have appeared with that release (5.1.16 does not exhibit the bug). Repeat-By: $ bash -e -c 'x=$(In prior releases this produced an error message for the nonexistent file but then continued to print 'hello'; in bash 5.2 and later it exits with a non-zero exit status immediately after issuing the error message without proceeding to the 'echo' command. The same behavior can be seen with an 'if' statement instead: $ bash -e -c 'if ! x=$(
Process-substitution FDs closed prematurely
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-unknow uname output: Linux hatter.bewilderbeest.net 3.4.4-2-ARCH #1 SMP PREEMPT Sun Jun 24 18:59:47 CEST 2012 x86_64 GNU/Linux Machine Type: x86_64-unknown-linux-gnu Bash Version: 4.2 Patch Level: 39 Release Status: release Description: It seems that when bash passes (the expanded form of) a process substitution to a function and that function then uses the argument in a pipeline, the file descriptor for the substituted pipe gets closed prematurely. This does not occur with bash-4.1.11 on FreeBSD, but does with 4.2.39 on Linux (I attempted to compile 4.1.11 from source on Linux to test it, but the build failed). Repeat-By: Shell transcript demonstrating it: [zev@hatter: tmp]% cat test.sh #!/bin/bash fn() { cat | cat "$1"; } fn <(:) < /dev/null [zev@hatter: tmp]% bash ./test.sh cat: /dev/fd/63: No such file or directory [zev@hatter: tmp]% echo $? 1 Expected behavior is no output and an exit status of zero.