diff options
author | 2011-03-09 09:30:39 +0000 | |
---|---|---|
committer | 2011-03-09 09:30:39 +0000 | |
commit | 30e9b9ef127769aca5e37b31ca789a4d4aead1b6 (patch) | |
tree | f681c55cc51edcf5f54d8d40a8c35dd1e9591b22 | |
parent | Move rc_pre and rc_post out of the rc_start/rc_stop functions into the (diff) | |
download | wireguard-openbsd-30e9b9ef127769aca5e37b31ca789a4d4aead1b6.tar.xz wireguard-openbsd-30e9b9ef127769aca5e37b31ca789a4d4aead1b6.zip |
substitute '~' for $HOME in the \W prompt case; matches bash's behavior.
feedback from Dan Harnett
OK deraadt@
-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", |