Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

exec | wc isn't very useful...


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

Equivalently, a sometimes appealing alternative to:

	echo foo
	echo bar
    ) > xyzzy.txt


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



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

Messages sorted by: Reverse Date, Date, Thread, Author