zsh-users
 help / color / mirror / code / Atom feed
From: Hannu Koivisto <azure@iki.fi>
To: "Zsh Users' List" <zsh-users@sunsite.auc.dk>
Subject: Re: Better ( rm foo; bar > foo ) < foo ?
Date: 04 Dec 2000 01:17:58 +0200	[thread overview]
Message-ID: <873dg5drh5.fsf@senstation.vvf.fi> (raw)
In-Reply-To: <1001203174821.ZM12458@candle.brasslantern.com>

"Bart Schaefer" <schaefer@candle.brasslantern.com> writes:

| How about
| 
| 	mv -i =(bar < foo) foo

At first I thought this is cool and very close to what I was
looking for but...

| ??  As long as `bar' produces some kind of failure output, that should be OK

...it seems you mean I have to have that -i there and wait and see
if bar says something went wrong and then tell mv not to
overwrite.  A little test seems to indicate this is indeed how =()
works, i.e. without -i it would run mv even if bar returns false.
I think I prefer your rewrite suggestion below.

| A little more input on what you think would NOT be clumsy would help.  For

That three-liner I wrote is too clumsy for throw-away-scripting; I
guess I was fantasizing about something like
sed 's/foo/bar/g' <> foo (with something else in place of <> since
that seems to be in use already) but I think anything that keeps
one-liners as one-liners is ok, like that rewrite below.

| example, would
| 
| 	rewrite sed 's/foo/bar/g' foo
| be OK?  Just take your original "in a script, I'd probably write" and put

It would be ok.

| it in a function:
| 
|     rewrite() {
| 	local TMPFILE=${TMPPREFIX}rewrite.$$	# Whatever
| 	$argv[1,-2] < $argv[-1] > $TMPFILE || rm -f $TMPFILE
| 	[[ -f $TMPFILE ]] && mv -f $TMPFILE $argv[-1]
|     }

Thanks, this is what I thought of first too, but I got greedy and I
wanted the hypothetical ideal way to work so that I could also
redirect the output to another place at the same time,
i.e. something like sed 's/foo/bar/g' <> foo > bar | baz and I
couldn't figure out how to include that to such function-approach
as rewrite, so I dropped the idea, but, well, I guess that rewrite
is just fine after all.

Clint Adams <schizo@debian.org> writes:

| I find that
| 
| perl -pi -e 's/foo/bar/g' $FILE
| 
| is much less of a hassle, if that's the complexity you're dealing with.

I find that Perl equals to pain, so I try to avoid it any way I
can (fortunately there is no Perl for my new machine, I think) :)
In any case, that sed thing was just an example, I was trying to
find a general way.

Thanks anyway,
-- 
Hannu


  reply	other threads:[~2000-12-04  0:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-03 14:01 Hannu Koivisto
2000-12-03 17:48 ` Bart Schaefer
2000-12-03 23:17   ` Hannu Koivisto [this message]
2000-12-04  2:27     ` Bart Schaefer
2000-12-03 20:24 ` Clint Adams
2000-12-07 11:44 ` Danny Dulai
2000-12-07 14:17   ` Andrej Borsenkow
2000-12-07 17:10     ` Bart Schaefer

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=873dg5drh5.fsf@senstation.vvf.fi \
    --to=azure@iki.fi \
    --cc=zsh-users@sunsite.auc.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).