Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug: bracketed-paste-magic + ztcp causes wrong pasted contents for CJK payloads



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



Messages sorted by: Reverse Date, Date, Thread, Author