From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23427 invoked from network); 16 Aug 2005 16:51:24 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 16 Aug 2005 16:51:24 -0000 Received: (qmail 11589 invoked from network); 16 Aug 2005 16:51:16 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 16 Aug 2005 16:51:16 -0000 Received: (qmail 26242 invoked by alias); 16 Aug 2005 16:51:09 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9325 Received: (qmail 26232 invoked from network); 16 Aug 2005 16:51:08 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 16 Aug 2005 16:51:08 -0000 Received: (qmail 10550 invoked from network); 16 Aug 2005 16:51:08 -0000 Received: from ns9.hostinglmi.net (213.194.149.146) by a.mx.sunsite.dk with SMTP; 16 Aug 2005 16:51:01 -0000 Received: from 212.red-80-35-44.pooles.rima-tde.net ([80.35.44.212] helo=localhost) by ns9.hostinglmi.net with esmtpa (Exim 4.51) id 1E54eW-0000R6-MH for zsh-users@sunsite.dk; Tue, 16 Aug 2005 18:51:05 +0200 Date: Tue, 16 Aug 2005 18:54:33 +0200 From: DervishD To: Zsh Users Subject: Re: Replacing sed for zsh portability Message-ID: <20050816165433.GA2131@DervishD> Mail-Followup-To: Zsh Users References: <20050815103557.GA1411@DervishD> <20050816154033.GY10992@ay.vinc17.org> <20050816155114.GA1854@DervishD> <20050816161814.GA10992@ay.vinc17.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20050816161814.GA10992@ay.vinc17.org> User-Agent: Mutt/1.4.2.1i Organization: DervishD X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - ns9.hostinglmi.net X-AntiAbuse: Original Domain - sunsite.dk X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - dervishd.net X-Source: X-Source-Args: X-Source-Dir: X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.4 Hi Vincent :) * Vincent Lefevre 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...