From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8190 invoked from network); 10 Jan 2006 16:49:02 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Jan 2006 16:49:02 -0000 Received: (qmail 65150 invoked from network); 10 Jan 2006 16:48:57 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Jan 2006 16:48:57 -0000 Received: (qmail 26056 invoked by alias); 10 Jan 2006 16:48:54 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22151 Received: (qmail 26047 invoked from network); 10 Jan 2006 16:48:54 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Jan 2006 16:48:54 -0000 Received: (qmail 64856 invoked from network); 10 Jan 2006 16:48:53 -0000 Received: from cluster-c.mailcontrol.com (HELO rly27c.srv.mailcontrol.com) (168.143.177.190) by a.mx.sunsite.dk with SMTP; 10 Jan 2006 16:48:51 -0000 Received: from exchange03.csr.com (uuk202166.uk.customer.alter.net [62.189.241.194] (may be forged)) by rly27c.srv.mailcontrol.com (MailControl) with ESMTP id k0AGk7Xk005976 for ; Tue, 10 Jan 2006 16:48:47 GMT Received: from news01 ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 10 Jan 2006 16:47:26 +0000 Date: Tue, 10 Jan 2006 16:47:25 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: Buggy zed function Message-Id: <20060110164725.52e277d4.pws@csr.com> In-Reply-To: <20060110161021.GG3585@prunille.vinc17.org> References: <20060110161021.GG3585@prunille.vinc17.org> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 10 Jan 2006 16:47:26.0492 (UTC) FILETIME=[898BB5C0:01C61605] X-Scanned-By: MailControl A-05-40-01 (www.mailcontrol.com) on 10.67.0.137 Vincent Lefevre wrote: > dixsept% which fctest > fctest () { > cat <<< 'foo > bar' > } > dixsept% fctest > foo > bar > dixsept% autoload zed > dixsept% zed -f fctest > fctest () { > cat <<< 'foo > bar' > } > dixsept% which fctest > fctest () { > cat <<< "'foo > bar'" > } It's not zed, you can see it just by entering fctest () { cat <<< 'foo bar' } which fctest The argument from a here string is output in a slightly strange way. The only reason I can see is for just the case you have, when it's been input as a here document. In that case it's a raw string and needs quoting. I think that's OK; it's the other case that needs changing. As far as I know, we never get there directly from a here document since that shouldn't produce tokens, so it should be good enough just to output that as a normal string without the extra layer of quoting. However, there may be a case I've missed... Index: Src/text.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/text.c,v retrieving revision 1.15 diff -u -r1.15 text.c --- Src/text.c 12 Apr 2005 15:11:12 -0000 1.15 +++ Src/text.c 10 Jan 2006 16:38:16 -0000 @@ -798,16 +798,17 @@ taddstr(fstr[f->type]); if (f->type != REDIR_MERGEIN && f->type != REDIR_MERGEOUT) taddchr(' '); - if (f->type == REDIR_HERESTR) { - if (has_token(f->name)) { - taddchr('\"'); - taddstr(bslashquote(f->name, NULL, 2)); - taddchr('\"'); - } else { - taddchr('\''); - taddstr(bslashquote(f->name, NULL, 1)); - taddchr('\''); - } + if (f->type == REDIR_HERESTR && !has_token(f->name)) { + /* + * Strings that came from here-documents are converted + * to here strings without quotation, so add that + * now. If tokens are already present taddstr() + * will do the right thing (anyway, adding more + * quotes certainly isn't right in that case). + */ + taddchr('\''); + taddstr(bslashquote(f->name, NULL, 1)); + taddchr('\''); } else taddstr(f->name); taddchr(' '); -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 Your mail client is unable to display the latest news from CSR. To access our news copy this link into a web browser: http://www.csr.com/email_sig.html