zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers <zsh-workers@sunsite.dk>
Subject: Re: Don't ask why i was trying to do this...
Date: Sun, 5 Nov 2006 22:46:52 +0000	[thread overview]
Message-ID: <20061105224652.ed8b8c7b.p.w.stephenson@ntlworld.com> (raw)
In-Reply-To: <237967ef0611041623ie8b3070nb2b1ffa4b6a2aef3@mail.gmail.com>

On Sun, 5 Nov 2006 01:23:37 +0100
"Mikael Magnusson" <mikachu@gmail.com> wrote:
> I'm not sure if this is supposed to work or not,
> print $(eval "echo -n '\\U'{1..200}")
> outputs the first 200 codepoints on stdout more or less correctly,
> print -z $(eval "echo -n '\\U'{1..200}")
> only pushes up until 3 characters after 'y' to the editing stack.

Right, normal print handles unmetafied output correctly, but options -z
as well as -s don't.  \U83 contains a character which, when unmetafied,
looks just like the Meta character.  It's therefore very useful for
testing.  (As you probably already know, \U assumes the argument is
hexadecimal, so the '\\U'{1..200}, which gives it decimal numbers, is a
bit illogical, but that's not relevant to the bug.)

This bug isn't new---someone decided it would be fantastic for
getkeystring(), which does interpretation of character escapes for
print, to return unmetafied output, since it would be easy to fix up
bin_print() to handle that, wouldn't it?  It isn't even documented.

(In case you think I sound bitter, the motto of the CSR firmware group
used to be "non sumus amari", which is Latin for "we're not bitter".)

By the way, a rewrite of getkeystring() is part of my improvement for
unquoting in completion, if that ever sees the light of day.  Sorry,
doing it again.

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.164
diff -u -r1.164 builtin.c
--- Src/builtin.c	5 Oct 2006 21:53:26 -0000	1.164
+++ Src/builtin.c	5 Nov 2006 21:38:40 -0000
@@ -3454,6 +3454,14 @@
     else \
 	count += fprintf(fout, spec, width, VAL);
 
+/*
+ * Because of the use of getkeystring() to interpret the arguments,
+ * the elements of args spend a large part of the function unmetafied
+ * with the lengths in len.  This may have seemed a good idea once.
+ * As we are stuck with this for now, we need to be very careful
+ * deciding what state args is in.
+ */
+
 /**/
 int
 bin_print(char *name, char **args, Options ops, int func)
@@ -3727,6 +3735,14 @@
     
     /* normal output */
     if (!fmt) {
+	if (OPT_ISSET(ops, 'z') || OPT_ISSET(ops, 's')) {
+	    /*
+	     * We don't want the arguments unmetafied after all.
+	     */
+	    for (n = 0; n < argc; n++)
+		metafy(args[n], len[n], META_NOALLOC);
+	}
+
 	/* -z option -- push the arguments onto the editing buffer stack */
 	if (OPT_ISSET(ops,'z')) {
 	    queue_signals();

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


      parent reply	other threads:[~2006-11-05 21:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-05  0:23 Mikael Magnusson
2006-11-05  2:24 ` Bart Schaefer
2006-11-05 13:48   ` Mikael Magnusson
2006-11-05 22:46 ` 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=20061105224652.ed8b8c7b.p.w.stephenson@ntlworld.com \
    --to=p.w.stephenson@ntlworld.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).