On Tue 2011.03.08 at 11:56 -0500, Dan Harnett wrote:
> On Tue, Mar 08, 2011 at 11:01:38AM -0500, Okan Demirmen wrote:
> > On Tue 2011.03.08 at 09:44 -0500, Dan Harnett wrote:
> > > This doesn't belong there. This effective turns \W into \w if the path
> > > is somewhere in the user's home directory. Without that conditional, it
> > > matches bash.
> >
> > bah, but I liked that :) however, you are correct...smaller diff below:
>
> > - strlcpy(strbuf, basename(p), sizeof strbuf);
> > + n = strlen(str_val(global("HOME")));
>
> I don't believe you need to set n anymore, as it's unused here.
>
> Otherwise, ok danh@
uhg, not my day.
Index: ksh.1
===================================================================
RCS file: /home/open/anoncvs/cvs/src/bin/ksh/ksh.1,v
retrieving revision 1.138
diff -u -p -r1.138 ksh.1
--- ksh.1 20 Sep 2010 07:41:17 -0000 1.138
+++ ksh.1 8 Mar 2011 08:42:53 -0000
@@ -1622,6 +1622,9 @@ is abbreviated as
.It Li \eW
The basename of
the current working directory.
+.Dv $HOME
+is abbreviated as
+.Sq ~ .
.It Li \e!
The current history number.
An unescaped
Index: lex.c
===================================================================
RCS file: /home/open/anoncvs/cvs/src/bin/ksh/lex.c,v
retrieving revision 1.44
diff -u -p -r1.44 lex.c
--- lex.c 3 Jul 2008 17:52:08 -0000 1.44
+++ lex.c 8 Mar 2011 17:07:07 -0000
@@ -1324,7 +1324,11 @@ dopprompt(const char *sp, int ntruncate,
break;
case 'W': /* '\' 'W' basename(cwd) */
p = str_val(global("PWD"));
- strlcpy(strbuf, basename(p), sizeof strbuf);
+ if (strcmp(p, str_val(global("HOME"))) == 0) {
+ strbuf[0] = '~';
+ strbuf[1] = '\0';
+ } else
+ strlcpy(strbuf, basename(p), sizeof
strbuf);
break;
case '!': /* '\' '!' history line number */
snprintf(strbuf, sizeof strbuf, "%d",