I am unsure why the first strcmp() is in place - possibly for if root's
HOME is /, but I don't think that was the case when this was put in.
In any case, I don't believe it is needed due the last else (diff with
more context below).
Thoughts?
Cheers,
Okan
Index: lex.c
===================================================================
RCS file: /home/okan/hack/open/cvs/src/bin/ksh/lex.c,v
retrieving revision 1.45
diff -u -p -U10 -r1.45 lex.c
--- lex.c 9 Mar 2011 09:30:39 -0000 1.45
+++ lex.c 14 Mar 2011 09:54:01 -0000
@@ -1303,23 +1303,21 @@ dopprompt(const char *sp, int ntruncate,
if (p)
*p = '\0';
}
break;
case 'V': /* '\' 'V' version (long) */
strlcpy(strbuf, ksh_version, sizeof strbuf);
break;
case 'w': /* '\' 'w' cwd */
p = str_val(global("PWD"));
n = strlen(str_val(global("HOME")));
- if (strcmp(p, "/") == 0) {
- strlcpy(strbuf, p, sizeof strbuf);
- } else if (strcmp(p, str_val(global("HOME")))
== 0) {
+ if (strcmp(p, str_val(global("HOME"))) == 0) {
strbuf[0] = '~';
strbuf[1] = '\0';
} else if (strncmp(p, str_val(global("HOME")),
n)
== 0 && p[n] == '/') {
snprintf(strbuf, sizeof strbuf, "~/%s",
str_val(global("PWD")) + n + 1);
} else
strlcpy(strbuf, p, sizeof strbuf);
break;
case 'W': /* '\' 'W' basename(cwd) */