[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why can't I say "&>&3"? Bug or feature?

From: Dan Douglas
Subject: Re: Why can't I say "&>&3"? Bug or feature?
Date: Thu, 06 Dec 2012 05:11:30 -0600
User-agent: KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; )

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]