Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: x86_64-pc-linux-gnu-gcc
Compilation CFLAGS: -O2 -pipe
uname output: Linux hikari 6.14.5 #4 SMP PREEMPT_DYNAMIC Thu May  8
06:32:53 CDT 2025 x86_64 Intel(R) Xeon(R) E-2324G CPU @ 3.10GHz
GenuineIntel GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.2
Patch Level: 37
Release Status: release

Description:
using the script:
#!/bin/bash
TMPFILE=$(mktemp /tmp/tmp.XXXX)
for a in this is a test; do
        if [ $a == 'a' ]; then
                >&2 echo b
        fi
done 2> >(echo "test!"> "$TMPFILE")

#touch "$TMPFILE"
if [ -s "$TMPFILE" ]; then
        echo temp file is not empty
else
        echo temp file is empty
fi
echo "Contents of $TMPFILE"
cat $TMPFILE
rm $TMPFILE

I get the output of:
temp file is empty
Contents of /tmp/tmp.LGvR
test!

if I touch or cat the TMPFILE before the test, it behaves as expected.

Reply via email to