zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Cc: Chi Hsuan Yen <yan12125@gmail.com>
Subject: Re: Bug: bracketed-paste-magic + ztcp causes wrong pasted contents for CJK payloads
Date: Tue, 27 Oct 2015 20:23:40 -0700	[thread overview]
Message-ID: <151027202340.ZM17146@torch.brasslantern.com> (raw)
In-Reply-To: <151027194317.ZM17099@torch.brasslantern.com>

On Oct 27,  7:43pm, Bart Schaefer wrote:
}
} (where $REPLY comes from "zle .read-command").  $REPLY is "self-insert"
} and $bpm_active is "self-*" so the first branch ought to be taken, and
} indeed that is what happens if ztcp has never been invoked.
} 
} However, if ztcp is run in the correct order with respect to the auto-
} load of bracketed-paste-magic, the case statement goes wrong and the
} (*) condition is taken instead.

AHA!

tcp.c uses setiparam("REPLY"), so depending on whether $REPLY is already
defined or not, it gets initialized as an integer-typed variable, which
means that when "self-insert" is assigned to REPLY, it's treated as an
arithmetic expression and evaluates to 0.

tcp.c, socket.c, and zpty.c all use setiparam("REPLY"), potentially
inflicting this on other modules that later do setsparam("REPLY").  Yet
another reason for Kurtis to run for the hills.

Here's the bracketed-paste-magic repair, but we should consider whether
those modules should be setting REPLY as a string instead.


diff --git a/Functions/Zle/bracketed-paste-magic b/Functions/Zle/bracketed-paste-magic
index 2368bc3..2b2bc63 100644
--- a/Functions/Zle/bracketed-paste-magic
+++ b/Functions/Zle/bracketed-paste-magic
@@ -122,7 +122,7 @@ bracketed-paste-magic() {
 	return
     else
 	# Capture the pasted text in $PASTED
-	local PASTED
+	local PASTED REPLY
 	zle .bracketed-paste PASTED
     fi
 
@@ -170,14 +170,14 @@ bracketed-paste-magic() {
 	while [[ -n $PASTED ]] && zle .read-command; do
 	    PASTED=${PASTED#$KEYS}
 	    if [[ $KEYS = ${(~j:|:)${(b)bpm_inactive}} ]]; then
-		zle .self-insert-unmeta
+		zle .self-insert
 	    else
 		case $REPLY in
 		    (${~bpm_active}) function () {
 			emulate -L $bpm_emulate; set -$bpm_opts
 			zle $REPLY
 		    };;
-		    (*) zle .self-insert-unmeta;;
+		    (*) zle .self-insert;;
 		esac
 	    fi
 	done


  reply	other threads:[~2015-10-28  3:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-15 13:54 Chi Hsuan Yen
2015-10-15 20:54 ` Bart Schaefer
2015-10-16  0:25   ` Bart Schaefer
2015-10-16 19:40     ` Chi Hsuan Yen
2015-10-18 15:52       ` Bart Schaefer
2015-10-18 16:19         ` Chi Hsuan Yen
2015-10-28  2:43     ` Bart Schaefer
2015-10-28  3:23       ` Bart Schaefer [this message]
2015-10-28  9:35         ` Peter Stephenson
2015-10-28 17:07           ` Bart Schaefer
2015-10-28 17:44             ` Peter Stephenson
2015-10-28 23:38               ` Bart Schaefer
2015-10-29  9:31                 ` Peter Stephenson
2015-10-29 14:51                   ` Peter Stephenson
2015-10-29 15:00                     ` Bart Schaefer
2015-10-29 15:10                       ` Peter Stephenson
2015-10-29 16:25                     ` Jun T.
2015-10-29 16:56                       ` Peter Stephenson
2015-10-30 15:02                         ` Daniel Shahaf
2015-11-03 16:31                           ` Chi Hsuan Yen

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=151027202340.ZM17146@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=yan12125@gmail.com \
    --cc=zsh-workers@zsh.org \
    /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).