From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8459 invoked from network); 14 Sep 2008 16:44:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 14 Sep 2008 16:44:09 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 82291 invoked from network); 14 Sep 2008 16:43:50 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 Sep 2008 16:43:50 -0000 Received: (qmail 17918 invoked by alias); 14 Sep 2008 16:43:46 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25669 Received: (qmail 17902 invoked from network); 14 Sep 2008 16:43:45 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 14 Sep 2008 16:43:45 -0000 Received: from vms173003pub.verizon.net (vms173003pub.verizon.net [206.46.173.3]) by bifrost.dotsrc.org (Postfix) with ESMTP id 82E80802710A for ; Sun, 14 Sep 2008 18:43:40 +0200 (CEST) Received: from torch.brasslantern.com ([96.238.220.178]) by vms173003.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0K7700BUU2GBHD75@vms173003.mailsrvcs.net> for zsh-workers@sunsite.dk; Sun, 14 Sep 2008 11:43:24 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id m8EGhMNm022701 for ; Sun, 14 Sep 2008 09:43:23 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id m8EGhMZC022700 for zsh-workers@sunsite.dk; Sun, 14 Sep 2008 09:43:22 -0700 Date: Sun, 14 Sep 2008 09:43:22 -0700 From: Bart Schaefer Subject: Re: promptsubst and empty variables In-reply-to: <20080914092459.GK2182@fsst.voodoo.lan> To: zsh workers Message-id: <080914094322.ZM22699@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <20080914092459.GK2182@fsst.voodoo.lan> Comments: In reply to Frank Terbeck "promptsubst and empty variables" (Sep 14, 11:24am) X-Virus-Scanned: ClamAV 0.92.1/8236/Sun Sep 14 16:07:34 2008 on bifrost X-Virus-Status: Clean On Sep 14, 11:24am, Frank Terbeck wrote: } } I am seeing some weirdness using prompt_subst and empty variables in } RPS1 (from zsh -f): } } [snip] } setopt promptsubst } RPROMPT='${foo}' I get the misplaced cursor right here; there doesn't need to be a value assigned to PROMPT with or without a substitution in it. } This results in the following cursor position: } } ~%_ } ^- At the underscore, that's where the cursor is. Note, the missing } trailing space. } } + it is in every version starting from 3.1.6 except: } - 4.3.1 and 4.3.2 } - it's back in 4.3.3 and remains to be in the CVS HEAD } version. I can't follow how any of the 4.3.0->4.3.1 changes could have affected this, but anyway ... The problem is that singsub() called from promptexpand() is returning nulstring, which is the Nularg token followed by a NUL byte. This is incorrectly being interpreted by promptexpand() as a so-called "glitch" space passed down from the caller, and is therefore counted as one space in the width of the prompt. Unfortunately having learned this much, I have very little idea how to proceed with fixing it. One possibility might be to do a first pass over the string counting and removing all "glitches" before making the call to singsub(), so that Nularg introduced by substitution could be ignored in a second pass. Another might be to introduce a real token for the "glitch" space rather than overloading Nularg, but that may have pretty wide-ranging ramifications. Wayne, this is mostly your baby. What to do?