zsh-users
 help / color / mirror / code / Atom feed
* exec | wc isn't very useful...
@ 2004-12-15 18:59 Anthony Heading
  2004-12-15 19:18 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Anthony Heading @ 2004-12-15 18:59 UTC (permalink / raw)
  To: zsh-users


Hi,

Can anyone tell me why this doesn't do what I'd hope:

    exec | wc

I'm wondering how to redirect the shell's "default" stdout into
a process, e.g. do the equivalent of perl's

    open(STDOUT, "| wc");
    print "two words";

Obviously one can do "echo two words | wc", or "wc <(echo two words)"
or whatever, but that doesn't seem to lend itself too well to
conditional redirection, viz:

    case $out in
	script)  exec > script.out ;;
	gnuplot) exec | gnuplot ;;  # doesn't work - hmm
	stdout) ;;
    esac

Equivalently, a sometimes appealing alternative to:

    (
	echo foo
	echo bar
    ) > xyzzy.txt

is

    exec > xyzzy.txt
    echo foo
    echo bar

but this doesn't seem to work for pipelines.  Except that
perl can do it no trouble...

Pointers to anything I'm missing very welcome...

Rgds

Anthony

This communication is for informational purposes only.  It is not intended
as an offer or solicitation for the purchase or sale of any financial
instrument or as an official confirmation of any transaction. All market prices,
data and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein 
do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries 
and affiliates


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-12-16 13:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-15 18:59 exec | wc isn't very useful Anthony Heading
2004-12-15 19:18 ` Peter Stephenson
2004-12-15 22:51   ` Anthony Heading
2004-12-16 13:50     ` Peter Stephenson

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).