From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10007 invoked by alias); 7 Feb 2017 09:01:41 -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: 40510 Received: (qmail 11121 invoked from network); 7 Feb 2017 09:01:41 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-0.7/5.0):. Processed in 2.341956 secs); 07 Feb 2017 09:01:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=Xp8Iq6z/ygQyezR eRNpGix/1ym0=; b=t1OUERZ1/eMfCfZP1FHPtKuQyENl1u4+V9CNtWIDKMkyskf O6xDmg263WSyrlzu8KbwQXM0CQZRVbPMgIiO7Q4i6Jv+OEJxCD8x5HqLVo4XkSwy LfKOIEB6YSKkUlIo/VYHMPdZXNK19kwMVL4xQrZ3zzGPLtd4vwwbvOSbDDgM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=Xp8Iq6z/ygQyez ReRNpGix/1ym0=; b=lF2pI/BobKhVw/j0PLhRCRj4SMF3hZ4rZ4Bh5cl32Y4Gi4 ZVurh3O+4bKzIBUgAmcsOkLxLxjC/u2I4wKxpNXmRWtD+MoYmUbWnnMByV7w6eM+ mymG5nhi1V6If5xHoZB8gH6vdt6+H7OafySPdXIrewEshUdw6UCBPpN9sa5fo= X-ME-Sender: X-Sasl-enc: rKnq2WXclOf7CdK0VrrCdSbyLbgUhNt8HMXiZXcWLGE7 1486458091 Date: Tue, 7 Feb 2017 08:57:33 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: [PATCH] vcs_info: Escape '%' signs in payloads Message-ID: <20170207085733.GA6158@fujitsu.shahaf.local2> References: <871svt8v4i.fsf@ft.bewatermyfriend.org> <1486283293-2586-1-git-send-email-danielsh@fujitsu.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1486283293-2586-1-git-send-email-danielsh@fujitsu.shahaf.local2> User-Agent: Mutt/1.5.23 (2014-03-12) Daniel Shahaf wrote on Sun, Feb 05, 2017 at 08:28:13 +0000: > +++ b/README > @@ -62,6 +62,15 @@ Note that functions including a non-leading / behave as before, > e.g. if `dir/name' is found anywhere under a directory in $fpath it is > loaded as a function named `dir/name'. > > +3) vcs_info: When neither a set-patch-format nor a gen-applied-string > +(resp. gen-unapplied-string) hook is set, vcs_info now '%'-escapes the > +applied-string (resp. unapplied-string) before interpolating it into the > +patch-format string, to prevent literal `%' signs in the interpolated > +value from being interpreted as prompt escape sequences. If you use > +${vcs_info_msg_0_} in a context other than the shell prompt, you may need > +to undo the escaping with: > + print -v vcs_info_msg_0_ -Pr -- "${vcs_info_msg_0_}" Another variant of this: the "Episode II" variant in Misc/vcs_info-examples expected $vcs_info_msg_0_ to be a literal string, whereas "Episode I" and "Episode III" expected $vcs_info_msg_0_ to be prompt-escaped. Since we can't be backwards compatible with both of the different semantics, I'm voting for breaking the psvar syntax, on the assumption that it's less widely used. (so that'd be the lesser of two evils) The failure mode for people who upgrade to vcs_info 5.4 without applying the following patch to their dotfiles' precmd functions is that any and all literal % signs in patch subjects would be doubled; so a patch that said "10% optimization" would render as "10%% optimization". Cheers, Daniel P.S. Tangent: I've been wondering how many people know that if they put %m in their actionformats, they can get information about in-progress rebases into their prompts. That detail seems to be buried in the depths of the reference manual... diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples index 766eb82..58dd8cf 100644 --- a/Misc/vcs_info-examples +++ b/Misc/vcs_info-examples @@ -31,7 +31,7 @@ precmd() { psvar=() vcs_info - [[ -n $vcs_info_msg_0_ ]] && psvar[1]="$vcs_info_msg_0_" + [[ -n $vcs_info_msg_0_ ]] && print -v 'psvar[1]' -Pr -- "$vcs_info_msg_0_" } # You can now use `%1v' to drop the $vcs_info_msg_0_ contents in your prompt; diff --git a/README b/README index 594b6f1..432a35e 100644 --- a/README +++ b/README @@ -69,8 +69,11 @@ patch-format string, to prevent literal `%' signs in the interpolated value from being interpreted as prompt escape sequences. If you use ${vcs_info_msg_0_} in a context other than the shell prompt, you may need to undo the escaping with: + print -v vcs_info_msg_0_ -Pr -- "${vcs_info_msg_0_}" +This is also needed if $vcs_info_msg_0_ is used to set $psvar. + Incompatibilities between 5.0.8 and 5.3 ----------------------------------------