Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Don't ask why i was trying to do this...
- X-seq: zsh-workers 22968
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers <zsh-workers@xxxxxxxxxx>
- Subject: Re: Don't ask why i was trying to do this...
- Date: Sun, 5 Nov 2006 22:46:52 +0000
- In-reply-to: <237967ef0611041623ie8b3070nb2b1ffa4b6a2aef3@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <237967ef0611041623ie8b3070nb2b1ffa4b6a2aef3@xxxxxxxxxxxxxx>
On Sun, 5 Nov 2006 01:23:37 +0100
"Mikael Magnusson" <mikachu@xxxxxxxxx> 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@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author