zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: Buggy zed function
Date: Tue, 10 Jan 2006 16:47:25 +0000	[thread overview]
Message-ID: <20060110164725.52e277d4.pws@csr.com> (raw)
In-Reply-To: <20060110161021.GG3585@prunille.vinc17.org>

Vincent Lefevre <vincent@vinc17.org> 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 <pws@csr.com>                  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


      reply	other threads:[~2006-01-10 16:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-10 16:10 Vincent Lefevre
2006-01-10 16:47 ` Peter Stephenson [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=20060110164725.52e277d4.pws@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@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).