diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2011-03-09 09:30:40 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2011-03-09 09:30:40 +0000 |
commit | 98b8c9146b2e1eb314a64e9bb31c8c46e8aca9a4 (patch) | |
tree | 87919803481927cba713a9985842e2dd01973734 /bin | |
parent | caa3601e4fa13bcec7cb29d1f57e612715d5bd9f (diff) |
substitute '~' for $HOME in the \W prompt case; matches bash's behavior.
feedback from Dan Harnett
OK deraadt@
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ksh/ksh.1 | 7 | ||||
-rw-r--r-- | bin/ksh/lex.c | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/bin/ksh/ksh.1 b/bin/ksh/ksh.1 index 131f23cfec8..6f9876b325b 100644 --- a/bin/ksh/ksh.1 +++ b/bin/ksh/ksh.1 @@ -1,8 +1,8 @@ -.\" $OpenBSD: ksh.1,v 1.138 2010/09/20 07:41:17 jmc Exp $ +.\" $OpenBSD: ksh.1,v 1.139 2011/03/09 09:30:39 okan Exp $ .\" .\" Public Domain .\" -.Dd $Mdocdate: September 20 2010 $ +.Dd $Mdocdate: March 9 2011 $ .Dt KSH 1 .Os .Sh NAME @@ -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 diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c index ef741c68f83..da91ba68965 100644 --- a/bin/ksh/lex.c +++ b/bin/ksh/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.44 2008/07/03 17:52:08 otto Exp $ */ +/* $OpenBSD: lex.c,v 1.45 2011/03/09 09:30:39 okan Exp $ */ /* * lexical analysis and source input @@ -1324,7 +1324,11 @@ dopprompt(const char *sp, int ntruncate, const char **spp, int doprint) 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", |