On Thursday, December 06, 2012 11:48:09 AM Tim Friske wrote:
> Hi folks,
>
> why is it that I can't say:
>
> exec 3>/dev/null
> echo foobar &>&3
> # Error: "-bash: syntax error near unexpected token `&'"
>
> but the following works:
>
> echo foobar &>/dev/null
> echo foobar >&3 2>&3
>
> I think the succinct notation "&>&N" where N is some numbered file
> descriptor should work also. Is this behavior a bug or feature?
>
>
> Cheers,
> Tim
> --
> `~~~~°<
> C92A E44E CC19 58E2 FA35 4048 2217 3C6E 0338 83FC
dash and ksh interpret that syntax as "background the previous list element
and apply >&3 to the next command", which I tend to think is most correct.
mksh appears to do as you suggest. Bash fails to parse it.
I don't like &> to begin with. It makes the already cryptic redirection syntax
that beginners struggle to understand even more confusing by adding a
pointless shortcut with a non-obvious meaning instead of just being explicit.
If you don't understand the copy descriptor and all of a sudden see yet
another use for the & character to the left of a redirection operator, you're
going to be even more confused.
--
Dan Douglas