Given the preamble, foobar function and invocations of it:exec 3>/dev/null    function foobar { echo foo; echo bar >&2; }foobar >/dev/nullfoobar 2>/dev/nullfoobar &>/dev/nullfoobar &>&3Why doesn't the last simple command get executed by Bash? Instead Bash quits with:-bash: syntax error near unexpected token `&'
Why doesn't Bash accept `&>&3`, i.e. redirecting stdout and stderr to file descriptor 3?
bash;io redirection;file descriptors
That's because there is no operator &>&.There is an operator &> word that redirects both stdout and stderr to word.There is an operator [n]>& word that duplicates fd n (default 1) from fd word. As a special case, if n is empty, and word isn't a number, redirects both stdout and stderr to word.But that's it. There isn't a special syntax for file descriptors which you can combine with operators. There are just the operators, which can interpret their operands as file descriptors or filenames. And there isn't a &>& operator which redirects both stdout and stderr, and interprets its right operand as a file descriptor.Summary: There is no special syntax &n for file descriptors. The & belongs to the operator, not to the operand. There is no operator &>&.