Just looking for the difference between
2>&-
2>/dev/null
|&
&>/dev/null
>/dev/null 2>&1
and their portability with non-Bourne shells
like tcsh
, mksh
, etc.
Just looking for the difference between
and their portability with |
||||
For background:
First let's tackle the function of these. For reference see the Advanced Bash-Scripting Guide. Functions
|
|
We have a winner. But so there's no performance difference or some such with
2>&- vs 2>/dev/null (other than that some "poorly" written programs don't undrestand 2>&- correctly)?
–
Det
Apr 6 '13 at 14:38
|
||
|
|||
|
|||
|
&> was in bash from the start (and breaks Bourne and POSIX compatibility as it means something different there, though is unlikely to be hit). >& and |& come from (t)csh (and it's their only way to redirect stderr). They were in zsh from the start and have only been added recently to bash . See also rc for better designed operators.
–
Stéphane Chazelas
Oct 24 at 9:26
|
This is for redirecting the STDERR & STDOUT:
These are all standard redirection methods for the Bourne shells. |
|||||
|
&>
for GNU bash compatibility, it’s strongly encouraged to not use this, as parsing it can break the semantics of existing POSIX scripts, and mksh disables that in POSIX mode already. – mirabilos Feb 27 at 13:56