From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27823 invoked from network); 15 Sep 2008 14:36:20 -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; 15 Sep 2008 14:36:20 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 44274 invoked from network); 15 Sep 2008 14:35:43 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Sep 2008 14:35:43 -0000 Received: (qmail 17532 invoked by alias); 15 Sep 2008 14:35:22 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25672 Received: (qmail 17438 invoked from network); 15 Sep 2008 14:35:19 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 15 Sep 2008 14:35:19 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id D85A480271AE for ; Mon, 15 Sep 2008 16:35:14 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly51d.srv.mailcontrol.com (MailControl) with ESMTP id m8FEZAJn018569 for ; Mon, 15 Sep 2008 15:35:10 +0100 Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Mon, 15 Sep 2008 15:34:57 +0100 Date: Mon, 15 Sep 2008 15:34:52 +0100 From: Peter Stephenson To: zsh workers Subject: Re: promptsubst and empty variables Message-ID: <20080915153452.68eeddbc@news01> In-Reply-To: <080914094322.ZM22699@torch.brasslantern.com> References: <20080914092459.GK2182@fsst.voodoo.lan> <080914094322.ZM22699@torch.brasslantern.com> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 15 Sep 2008 14:34:57.0699 (UTC) FILETIME=[3A1B6730:01C91740] X-Scanned-By: MailControl A-08-50-13 (www.mailcontrol.com) on 10.68.0.161 X-Virus-Scanned: ClamAV 0.92.1/8247/Mon Sep 15 14:04:53 2008 on bifrost X-Virus-Status: Clean On Sun, 14 Sep 2008 09:43:22 -0700 Bart Schaefer wrote: > 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. > > The problem is that singsub() called from promptexpand() is returning > nulstring, which is the Nularg token followed by a NUL byte. I hope, actually, it's dupstring(nulstring), or substitution is a bit broken. I don't think we need the Nularg in this case since although the string is metafied we're not doing anything special with tokens. However, I've never understood what this was for in the first place, so I may have missed something. If I have, however, we're not going to find out without trying it. Index: Src/prompt.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/prompt.c,v retrieving revision 1.52 diff -u -r1.52 prompt.c --- Src/prompt.c 24 Jun 2008 08:44:16 -0000 1.52 +++ Src/prompt.c 15 Sep 2008 14:27:44 -0000 @@ -169,6 +169,12 @@ s = dupstring(s); if (!parsestr(s)) singsub(&s); + /* + * We don't need the special Nularg hack here and we're + * going to be using Nularg for other things. + */ + if (*s == Nularg && s[1] == '\0') + *s = '\0'; /* Ignore errors and status change in prompt substitution */ errflag = olderr; -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070