summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2008-07-05 07:25:19 +0000
committerDamien Miller <djm@cvs.openbsd.org>2008-07-05 07:25:19 +0000
commit0e4975ba5f04c16243aa78c340470bc1960dec50 (patch)
treea21850894d4ea741fe34e4481038f98cd30c4078
parent46c043581f5e44fd5a1559bff4e2f42f3db6b230 (diff)
ksh starting as root will refuse to import a PS1 prompt unless it
contains a '#' character. Make it also accept the \$ PS1 sequence (which is supposed to automagically be $ or # depending on the user running the shell) unless ksh has been started in sh-compatibility mode. pointed out by millert@ when I asked why my SUDO_PS1 was not being honoured; ok millert@
-rw-r--r--bin/ksh/main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/bin/ksh/main.c b/bin/ksh/main.c
index 74c843cd50b..abacbfdd4fc 100644
--- a/bin/ksh/main.c
+++ b/bin/ksh/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.43 2007/05/31 20:47:44 otto Exp $ */
+/* $OpenBSD: main.c,v 1.44 2008/07/05 07:25:18 djm Exp $ */
/*
* startup, main loop, environments and error handling
@@ -246,10 +246,11 @@ main(int argc, char *argv[])
struct tbl *vp = global("PS1");
/* Set PS1 if it isn't set, or we are root and prompt doesn't
- * contain a #.
+ * contain a # or \$ (only in ksh mode).
*/
if (!(vp->flag & ISSET) ||
- (!ksheuid && !strchr(str_val(vp), '#')))
+ (!ksheuid && !strchr(str_val(vp), '#') &&
+ (Flag(FSH) || !strstr(str_val(vp), "\\$"))))
/* setstr can't fail here */
setstr(vp, safe_prompt, KSH_RETURN_ERROR);
}