File descriptor inheritance

$ diff -du <(cat) - <<< "foo"
cat: -: Input/output error
--- /dev/fd/63	2021-07-04 22:02:49.684001000 +0100
+++ -	2021-07-04 22:02:49.686762850 +0100
@@ -0,0 +1 @@
+foo
$ { diff -du <(cat) -; } <<< "foo"
--- /dev/fd/63	2021-07-04 22:03:04.119001000 +0100
+++ -	2021-07-04 22:03:04.121612176 +0100
@@ -1 +0,0 @@
-foo

In the first case only diff gets “foo” as STDIN. In the second case both diff and cat get the same STDIN FD and cat wins the race as it executes earlier.

Keep that in mind when re-directing STDIN for functions.