* Re: Bug#201685: zsh: bug in prompt expansion
2004-07-23 17:33 ` Bug#201685: zsh: bug in prompt expansion Clint Adams
@ 2004-07-23 18:02 ` Peter Stephenson
2004-07-26 17:14 ` Peter Stephenson
2004-07-27 9:18 ` Peter Stephenson
2 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2004-07-23 18:02 UTC (permalink / raw)
To: Clint Adams; +Cc: zsh-workers, Martin Godisch, 201685-forwarded
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
It does have at least one element; the problem is that /usr is still
regarded as a single element.
It could be fixed by both redocumenting the count as distance from the
root directory in terms of path elements (rather than absolutely, which
is a bigger change), and changing the value for /. I don't know which
of the two more people would find more useful.
--
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
**********************************************************************
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug#201685: zsh: bug in prompt expansion
2004-07-23 17:33 ` Bug#201685: zsh: bug in prompt expansion 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
2 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2004-07-26 17:14 UTC (permalink / raw)
To: Clint Adams; +Cc: zsh-workers, Martin Godisch, 201685-forwarded
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
> .
This would fix this.
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
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug#201685: zsh: bug in prompt expansion
2004-07-26 17:14 ` Peter Stephenson
@ 2004-07-29 11:46 ` Peter Stephenson
0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2004-07-29 11:46 UTC (permalink / raw)
To: zsh-workers, 201685-forwarded
Peter Stephenson wrote:
> 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 eleme
> nt
> > .
>
> This would fix this.
Nobody commented on this, so I've committed it. I imagine it's under
most people's radar.
--
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
**********************************************************************
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug#201685: zsh: bug in prompt expansion
2004-07-23 17:33 ` Bug#201685: zsh: bug in prompt expansion Clint Adams
2004-07-23 18:02 ` Peter Stephenson
2004-07-26 17:14 ` Peter Stephenson
@ 2004-07-27 9:18 ` Peter Stephenson
2 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2004-07-27 9:18 UTC (permalink / raw)
To: zsh-workers, 201685-forwarded
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
**********************************************************************
^ permalink raw reply [flat|nested] 5+ messages in thread