From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13367 invoked by alias); 25 Dec 2017 20:17:36 -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: List-Unsubscribe: X-Seq: 42166 Received: (qmail 19912 invoked by uid 1010); 25 Dec 2017 20:17:36 -0000 X-Qmail-Scanner-Diagnostics: from out2-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.26):SA:0(-2.6/5.0):. Processed in 2.198195 secs); 25 Dec 2017 20:17:36 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=ham 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: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=h4Ri2T tfGReicq1EeEmNvBMUE2915j23FKRTRJxApq8=; b=EnBiagUv2hV3CfAmStyb5f SbTB9vzxsotv41CCJ0hbhZGAa1gabpA1HgtbfIeAvBHFGHS9zolebY+i23Inzn+3 VDst/+p4k3WYgIFlR3sUs2iKVFPqvlka/Yhql6SMZUSexzOGqcBu+VqNg3W+HTM/ k6dXghTNdMO3pNWgzfRcKrH3h5Uxb8zlnbClFR5SI/eN17w+URvc7sy076SwApNg gQVZMFaGkywcgNTIhoTcQaMmiqODKTe5GNN7OCy2Z1VoCAYtnsO/Cu2ckBakwO8D 75Xjylda2v+TFfad7a1XxpMEFnteDZFWNunlsynUQ6b98YkY4951eKl/PdWEkNzA == DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=h4Ri2T tfGReicq1EeEmNvBMUE2915j23FKRTRJxApq8=; b=DzVzlmRdT/rWo0/3prt5B1 TXBPTaxkEKQFTphC74Si5AvnPmWTccWiaJ2TL9EBU7Hic2OqDLymUHNjJV3FBy9j nBvkmvUh2ISRkkBiMTFQvT7KW8OWszmuX50uPXMBHtRYRp8COx6uHNwEBWzw6D51 ZAGC7eVDU1XuKjoRM9N5KsuHlYotnONspwJfIghOmeN71SwPoF+gfq5lKdKfFg4q Bmm2SMJhNopHmUIZIygFHAbXZjC4tbu2z7bYn3qf4yqS8ZHZD358RAS5JGfbUIS+ VeEgoGeIErBBTOnjSGeLAEWeyQRrP5CVHxpJoTG7a5KcCyVTf2RpGyMJOTJ1RVSA == X-ME-Sender: Date: Mon, 25 Dec 2017 20:17:28 +0000 From: Daniel Shahaf To: Doron Behar Cc: zsh-workers@zsh.org Subject: Re: [BUG] vcs_info - git branch with % in it's name Message-ID: <20171225201728.6e2iwqm5loqbbjsr@tarpaulin.shahaf.local2> References: <20171225093306.6druy3zqyjx2rcyr@NUC.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20171225093306.6druy3zqyjx2rcyr@NUC.localdomain> User-Agent: NeoMutt/20170113 (1.7.2) Doron Behar wrote on Mon, 25 Dec 2017 11:33 +0200: > I think I found a bug within zsh's module vcs_info. > > If a user is in a git repository with a '%' as part of the name of the > branch and he has '%b' in his prompt, he might get weird results, like: > > doron   bla9269ello  ~/repos/abcde  > > Instead of: > > doron   bla%ello  ~/repos/abcde  > > Has anyone encountered this before? I wonder why it happens.. Prompt expansions and zformat both use % as an expando introducer. This is basically the same form of bug as doing *«printf(argv[1])» in C. %h is: %h %! Current history event number. (Incidentally, it is missing from «print -P %» completion) How about the following? If that is the right fix then the adjacent lines will need similar tweaking. diff --git a/Functions/VCS_Info/VCS_INFO_formats b/Functions/VCS_Info/VCS_INFO_formats index 4d0dd75c2..a46a10286 100644 --- a/Functions/VCS_Info/VCS_INFO_formats +++ b/Functions/VCS_Info/VCS_INFO_formats @@ -81,7 +81,7 @@ for i in {1..${#msgs}} ; do if VCS_INFO_hook "set-message" $(( $i - 1 )) "${msgs[$i]}"; then zformat -f msg ${msgs[$i]} \ a:${hook_com[action]} \ - b:${hook_com[branch]} \ + b:${hook_com[branch]//'%'/%%} \ c:${hook_com[staged]} \ i:${hook_com[revision]} \ m:${hook_com[misc]} \ Cheers, Daniel