zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk, 201685-forwarded@bugs.debian.org
Subject: Re: Bug#201685: zsh: bug in prompt expansion
Date: Tue, 27 Jul 2004 10:18:58 +0100	[thread overview]
Message-ID: <200407270918.i6R9Iw0m013293@news01.csr.com> (raw)
In-Reply-To: "Clint Adams"'s message of "Fri, 23 Jul 2004 13:33:22 EDT." <20040723173322.GA9988@scowler.net>

Clint Adams wrote:
> I don't remember if this was discussed before.
> 
> On Thu, Jul 17, 2003 at 11:33:11AM +0200, Martin Godisch wrote:
> > 
> > After PROMPT='%~%1(C./.) ' the full prompt should be `/ ' in the root
> > directory, because the absolute path `/' does not have at least one element

I sent a patch for this but can't see any sign of it having got
anywhere.

This should do what was asked for.  It's more logical but I don't know
if anyone out there is expecting the code simply to count slashes.

Index: Doc/Zsh/prompt.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/prompt.yo,v
retrieving revision 1.6
diff -u -r1.6 prompt.yo
--- Doc/Zsh/prompt.yo	2 Nov 2001 12:35:32 -0000	1.6
+++ Doc/Zsh/prompt.yo	26 Jul 2004 17:12:13 -0000
@@ -217,11 +217,13 @@
 sitem(tt(?))(True if the exit status of the last command was var(n).)
 sitem(tt(_))(True if at least var(n) shell constructs were started.)
 sxitem(tt(C))
-sitem(tt(/))(True if the current absolute path has at least var(n) elements.)
+sitem(tt(/))(True if the current absolute path has at least var(n) elements
+relative to the root directory, hence tt(/) is counted as 0 elements.)
 sxitem(tt(c))
 sxitem(tt(.))
 sitem(tt(~))(True if the current path, with prefix replacement, has at
-least var(n) elements.)
+least var(n) elements relative to the root directory, hence tt(/) is
+counted as 0 elements.)
 sitem(tt(D))(True if the month is equal to var(n) (January = 0).)
 sitem(tt(d))(True if the day of the month is equal to var(n).)
 sitem(tt(g))(True if the effective gid of the current process is var(n).)
Index: Src/prompt.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/prompt.c,v
retrieving revision 1.19
diff -u -r1.19 prompt.c
--- Src/prompt.c	22 Jun 2004 13:10:02 -0000	1.19
+++ Src/prompt.c	26 Jul 2004 17:12:14 -0000
@@ -244,9 +244,12 @@
 		    if ((nd = finddir(ss))) {
 			arg--;
 			ss += strlen(nd->dir);
-		    }
+		    } /*FALLTHROUGH*/
 		case '/':
 		case 'C':
+		    /* `/' gives 0, `/any' gives 1, etc. */
+		    if (*ss++ == '/' && *ss)
+			arg--;
 		    for (; *ss; ss++)
 			if (*ss == '/')
 			    arg--;

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


      parent reply	other threads:[~2004-07-27 21:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030717093311.GA9490@carlos.godisch.de>
2004-07-23 17:33 ` Clint Adams
2004-07-23 18:02   ` Peter Stephenson
2004-07-26 17:14   ` Peter Stephenson
2004-07-29 11:46     ` Peter Stephenson
2004-07-27  9:18   ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200407270918.i6R9Iw0m013293@news01.csr.com \
    --to=pws@csr.com \
    --cc=201685-forwarded@bugs.debian.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).