From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25821 invoked by alias); 28 Oct 2015 03:23:46 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36994 Received: (qmail 19978 invoked from network); 28 Oct 2015 03:23:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern_com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject:cc :mime-version:content-type; bh=CtgD9S/m2VEsChUo1pGH+ig9NYtBTZu7yFIrnrBaAVo=; b=cjiUsRijmlDFT3AQ30tnJu3SScGJRN5tDJrPlrSo0WCWXGkfuAX8T9eXO4XGIMm+/i W7vT0cKLW7U7Ly3U18f/jRdhFJGeujhvtdGUrgUF3DagizIBZJ1HkqZBLzhfuvJ9ir0v Pobi9bxPvOD8SpIyda4x28QiDX/50AkpZfWJMls4JtZHcfiNh4HQua9CBn6EywpzP5Px 7oRELsktUQs6EK18cXcJWCJ7kIpkJNjBKnLuIz3bUIPRWq9ZwjA4uZxGxjx8hoeswmZy bQTfHn2D5zO8ZRe4WedreXGjWIVTplkkD0o5TyzLtcHX/jNjephqVYy7QtbI23+OI4WX 6gAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:cc:mime-version:content-type; bh=CtgD9S/m2VEsChUo1pGH+ig9NYtBTZu7yFIrnrBaAVo=; b=FwaLVjEfJ/lrACbP/HGr4DNwJXHbRY36G+Ok5X1M4LMwScI601FpSPkX0cE+xVdcmj zmJUstXzrvUish/5FWC46kKZVUyhQAjJsDj3xE3KpLTiIhVS7Pa6RsbJmoA7yM+YgJR8 qzrsovbIuH3q1hHgMW5b1nxP72hgG3y3wGfC2msz1kFgSevWxtUKMA8XW/xVBXFl+byu 6rydZNHYWAUsaRO3UZjfRoXCUFt64PCmTStlt/L1pS9ZWOZ7vI0lbVeRGRkx9rUIej+g at+eqN23SAfW8BgXcnKetYO013u/7szG+URxGsy/aAXgJ9iCUb2tdhBxvT81y/GPO/YR xGpQ== X-Gm-Message-State: ALoCoQm3JvNDVDpqUKfFImop+vmQQlQSwSlf+ZqIXMfZ/GaKlpJUSIjuUq1Iomqxna1fVo1HB4Ac X-Received: by 10.202.81.8 with SMTP id f8mr17578717oib.40.1446002622809; Tue, 27 Oct 2015 20:23:42 -0700 (PDT) From: Bart Schaefer Message-Id: <151027202340.ZM17146@torch.brasslantern.com> Date: Tue, 27 Oct 2015 20:23:40 -0700 In-Reply-To: <151027194317.ZM17099@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: Bug: bracketed-paste-magic + ztcp causes wrong pasted contents for CJK payloads" (Oct 27, 7:43pm) References: <151015172503.ZM30721@torch.brasslantern.com> <151027194317.ZM17099@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh hackers list Subject: Re: Bug: bracketed-paste-magic + ztcp causes wrong pasted contents for CJK payloads Cc: Chi Hsuan Yen MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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