Currently, if ksh starts as root and PS1 was exported but doesn't contain '#' or '\$' (which will be expanded to '#') then it'll override it with the root default of '# '. This is kind of a corner case, because PS1 is not normally exported.
phessler's research seems to indicate that we're alone in behaving this way: everyone else seems to not check but just uses the exported PS1 blindly. This is making it difficult to port mininet to OpenBSD. Let's stop being different. ok? Philip Index: main.c =================================================================== RCS file: /data/src/openbsd/src/bin/ksh/main.c,v retrieving revision 1.82 diff -u -p -r1.82 main.c --- main.c 17 Oct 2016 17:44:47 -0000 1.82 +++ main.c 11 Aug 2017 15:16:36 -0000 @@ -313,14 +313,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 # or \$ (only in ksh mode). - */ - if (!(vp->flag & ISSET) || - (!ksheuid && !strchr(str_val(vp), '#') && - (Flag(FSH) || !strstr(str_val(vp), "\\$")))) + /* Set PS1 if it isn't set */ + if (!(vp->flag & ISSET)) { /* setstr can't fail here */ setstr(vp, safe_prompt, KSH_RETURN_ERROR); + } } /* Set this before parsing arguments */ Index: ksh.1 =================================================================== RCS file: /data/src/openbsd/src/bin/ksh/ksh.1,v retrieving revision 1.191 diff -u -p -r1.191 ksh.1 --- ksh.1 6 Jul 2017 15:42:04 -0000 1.191 +++ ksh.1 11 Aug 2017 15:17:09 -0000 @@ -1535,15 +1535,6 @@ The default prompt is for non-root users, .Sq #\ \& for root. -If -.Nm -is invoked by root and -.Ev PS1 -does not contain a -.Sq # -character, the default value will be used even if -.Ev PS1 -already exists in the environment. .Pp The following backslash-escaped special characters can be used to customise the prompt: