zsh-users
 help / color / mirror / code / Atom feed
From: Anthony Heading <aheading@jpmorgan.com>
To: zsh-users@sunsite.dk
Subject: exec | wc isn't very useful...
Date: Wed, 15 Dec 2004 13:59:20 -0500	[thread overview]
Message-ID: <20041215185920.GA24992@bretton.ny.jpmorgan.com> (raw)


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


             reply	other threads:[~2004-12-15 19:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-15 18:59 Anthony Heading [this message]
2004-12-15 19:18 ` Peter Stephenson
2004-12-15 22:51   ` Anthony Heading
2004-12-16 13:50     ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041215185920.GA24992@bretton.ny.jpmorgan.com \
    --to=aheading@jpmorgan.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).