zsh-users
 help / color / mirror / code / Atom feed
From: DervishD <zsh@dervishd.net>
To: Zsh Users <zsh-users@sunsite.dk>
Subject: Re: Replacing sed for zsh portability
Date: Tue, 16 Aug 2005 18:54:33 +0200	[thread overview]
Message-ID: <20050816165433.GA2131@DervishD> (raw)
In-Reply-To: <20050816161814.GA10992@ay.vinc17.org>

    Hi Vincent :)

 * Vincent Lefevre <vincent@vinc17.org> dixit:
> On 2005-08-16 17:51:14 +0200, DervishD wrote:
> >     The thing is perfectly suitable to be done in sed, in fact it is
> > a one-liner (three lines if non-GNU sed), and it can even be done in
> > one or two lines in Zsh. Introducing a dependency with Perl just for
> [...]
> The problem with sed is that it is non-portable, and it is difficult
> to be sure that a sed call will work as expected on any machine.

    I know, but both POSIX and SUS have standarized a (big) subset of
sed programs, and I would tell that 100% of the sed's out there
support the 's' command. In fact, a system without a working sed (I
mean, a sed that doesn't understand the 's' command) won't run
'configure' scripts properly and so is possible that zsh won't
compile on them, so...
 
> With zsh, things related to regexp are difficult to read, and the
> behaviour often depends on options (one needs to remember to use
> "emulate -LR zsh", and this should be OK, however).

    That's for sure, I will use 'emulate' because it ensures (more or
less) a sane default, known environment. And I don't care about
readability because Perl is not readable and the end user won't ever
see the regex, it's me who is going to maintain it ;)
 
> I've had to switch to Perl for a simple replacement just because
> in-place editing with sed isn't supported everywhere, and when it
> is supported, it doesn't behave in the same way on every machine.

    Well, in place editing is just a shortcut for doing a couple of
'mv's. The only problem can be side effects in the middle of the
moves, but if Perl does the in-place editing using a temporary file
and a rename... I don't know how it is done neither in Perl nor in
sed, anyway.

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...


      parent reply	other threads:[~2005-08-16 16:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-15 10:35 DervishD
2005-08-15 10:39 ` DervishD
2005-08-15 11:22 ` Peter Stephenson
2005-08-15 20:21   ` DervishD
2005-08-16 15:40 ` Vincent Lefevre
2005-08-16 15:51   ` DervishD
2005-08-16 16:18     ` Vincent Lefevre
2005-08-16 16:34       ` Oliver Kiddle
2005-08-16 18:02         ` Vincent Lefevre
2005-08-16 16:54       ` DervishD [this message]

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=20050816165433.GA2131@DervishD \
    --to=zsh@dervishd.net \
    --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).