| Sven Mascheck 2005-04-27, 2:48 am |
| Keith Thompson wrote:
> Janis Papanagnou writes:
>
>
> [...] all shells I know of (including csh and bash) allow it to
> be put just about anywhere.
There are a few exceptions to this general rule:
- redirections may only precede simple commands in POSIX.2
and traditional behaviour is varying
"< file { cmd; }" is illegal
(in contrast to "{ cmd; } < file")
because { } are not special like ( )
"< file ( cmd; )" is often legal
bash doesn't allow it (see its FAQ)
- "f() { cmd; } > file" gives unexpected and varying results
(this is more about orthogonality than usefulness)
- in Bourne shells, especially "2>&1 cmd >file"
interestingly also redirects stderr (except SunOS 5.6+)
historic:
- Bourne shells before SVR2 didn't allow to redirect a fd again
"eval 'cmd > file1' > file2"
Sven
--
|