* How to redirect stderr to a pipe and stdout to a file?
@ 2003-06-15 12:50 Haakon Riiser
2003-06-15 14:04 ` Erik Trulsson
2003-06-15 16:11 ` Pavol Juhas
0 siblings, 2 replies; 4+ messages in thread
From: Haakon Riiser @ 2003-06-15 12:50 UTC (permalink / raw)
To: zsh-users
In bash, I could always do
$ ls INVALID . 2>&1 >/dev/null | less
to send stderr:
ls: INVALID: No such file or directory
to the less buffer and stdout to /dev/null. When I use the
same command in zsh 4.0.6, _both_ stderr and stdout is sent
to less. If I remove "| less" from the command, it works as it
should: stdout is discarded and stderr is sent to the terminal.
I've looked through the chapter on redirection in zshmisc(1),
but I couldn't find an answer. (Of course, that doesn't mean
it's not there. :-)
Thanks in advance for any help.
--
Haakon
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to redirect stderr to a pipe and stdout to a file?
2003-06-15 12:50 How to redirect stderr to a pipe and stdout to a file? Haakon Riiser
@ 2003-06-15 14:04 ` Erik Trulsson
2003-06-15 16:11 ` Pavol Juhas
1 sibling, 0 replies; 4+ messages in thread
From: Erik Trulsson @ 2003-06-15 14:04 UTC (permalink / raw)
To: zsh-users
On Sun, Jun 15, 2003 at 02:50:30PM +0200, Haakon Riiser wrote:
> In bash, I could always do
>
> $ ls INVALID . 2>&1 >/dev/null | less
>
> to send stderr:
>
> ls: INVALID: No such file or directory
>
> to the less buffer and stdout to /dev/null. When I use the
> same command in zsh 4.0.6, _both_ stderr and stdout is sent
> to less. If I remove "| less" from the command, it works as it
> should: stdout is discarded and stderr is sent to the terminal.
> I've looked through the chapter on redirection in zshmisc(1),
> but I couldn't find an answer. (Of course, that doesn't mean
> it's not there. :-)
>
> Thanks in advance for any help.
I don't know what the real answer is, but a workaround (which should
also work in bash) is to execute the first command in a subshell, i.e:
( ls INVALID . 2>&1 >/dev/null ) | less
--
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to redirect stderr to a pipe and stdout to a file?
2003-06-15 12:50 How to redirect stderr to a pipe and stdout to a file? Haakon Riiser
2003-06-15 14:04 ` Erik Trulsson
@ 2003-06-15 16:11 ` Pavol Juhas
2003-06-15 17:43 ` Bart Schaefer
1 sibling, 1 reply; 4+ messages in thread
From: Pavol Juhas @ 2003-06-15 16:11 UTC (permalink / raw)
To: zsh-users
On Sun, Jun 15, 2003 at 02:50:30PM +0200, Haakon Riiser wrote:
> In bash, I could always do
>
> $ ls INVALID . 2>&1 >/dev/null | less
>
> to send stderr:
>
> ls: INVALID: No such file or directory
> to the less buffer and stdout to /dev/null. When I use the
> same command in zsh 4.0.6, _both_ stderr and stdout is sent
> to less. If I remove "| less" from the command, it works as it
> should: stdout is discarded and stderr is sent to the terminal.
...
You need to
setopt no_multios
and the redirection would work as expected. For explanation
see the MULTIOS section in zshmisc(1).
HTH,
Pavol
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to redirect stderr to a pipe and stdout to a file?
2003-06-15 16:11 ` Pavol Juhas
@ 2003-06-15 17:43 ` Bart Schaefer
0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2003-06-15 17:43 UTC (permalink / raw)
To: zsh-users
On Jun 15, 12:11pm, Pavol Juhas wrote:
} Subject: Re: How to redirect stderr to a pipe and stdout to a file?
}
} On Sun, Jun 15, 2003 at 02:50:30PM +0200, Haakon Riiser wrote:
} >
} > $ ls INVALID . 2>&1 >/dev/null | less
}
} You need to
} setopt no_multios
Multios are applied at the "pipeline" level of shell grammar, so you can
also prevent the effects by introducing any complex structure; easiest is
just to wrap the first command in { } like so:
% { ls INVALID . 2>&1 >/dev/null } | less
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-06-15 17:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-15 12:50 How to redirect stderr to a pipe and stdout to a file? Haakon Riiser
2003-06-15 14:04 ` Erik Trulsson
2003-06-15 16:11 ` Pavol Juhas
2003-06-15 17:43 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).