Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: x86_64-pc-linux-gnu-gcc Compilation CFLAGS: -march=native -O2 uname output: Linux ns3012044.ip-37-187-96.eu 4.9.120-xxxx-std-ipv6-64 #327490 SMP Thu Aug 16 10:11:35 UTC 2018 x86_64 Intel(R) Atom(TM) CPU N2800 @ 1.86GHz GenuineIntel GNU/Linux Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.1 Patch Level: 16 Release Status: release Description: Output redirections to variable file descriptors inside functions lead to incorrect representation (declare -f). Breaking exported functions. Reproductible with all bash versions from version 4.2 to latest version including beta. Reproductbile on all all platforms. Repeat-By: $ f(){ foo=1; printf test\\n >&"$foo"; }; declare -f f f () { foo=1; printf test\\n &> "$foo" } $ f test $ export -f f $ bash $ ls -l ./1 ls: cannot access './1': No such file or directory $ f $ ls -l ./1 -rw-r--r-- 1 lloyd lloyd 5 Jun 3 17:03 ./1 $ cat ./1 test $ The representation of the function is incorrect (&> redirects both stdin and stdout to files) Please note that the function works properly unless you export and use it or use the output of declare -f.