Re: '\$' or '#' must appear in PS1 in order to be properly exported as root?
On 01/06/11 23:10, Ezequiel Garzsn wrote: Greetings. This is my first post to the OpenBSD community, so please let me know if I'm in the wrong list, this is just too basic or any other faux pas. Under the default ksh, the default /root/.profile and indeed a completely fresh 4.8 install, adding the following line to /root/.profile does not work as expected: export PS1='$PWD ' From ksh(1): PS1The primary prompt for interactive shells. Parameter, /.../ The default prompt is `$ ' for non-root users, `# ' for root. If ksh is invoked by root and PS1 does not contain a `#' character, the default value will be used even if PS1 already exists in the environment. /Alexander The login shell is '/root ', which makes sense to me, but all child shells get the default '# ', despite PS1 being exported. Even more strange, this doesn't happen when PS1 contains '\$' or '#'; it looks like the hash must be in the root prompt. Non-root users are not affected by the equivalent restriction (PS1 may not contain '\$' or '$'). Could anyone point out why this happens? Can this behavior be modified? Coming from a fresh install, there is no /etc/profile or /root/.kshrc. Thank you in advance for your help. Cheers, Ezequiel
Re: '\$' or '#' must appear in PS1 in order to be properly exported as root?
On Thu, Jan 6, 2011 at 5:40 PM, Ezequiel GarzC3n garzon.luc...@gmail.com wrote: Greetings. This is my first post to the OpenBSD community, so please let me know if I'm in the wrong list, this is just too basic or any other faux pas. Under the default ksh, the default /root/.profile and indeed a completely fresh 4.8 install, adding the following line to /root/.profile does not work as expected: export PS1='$PWD ' PS1 shouldn't be exported Set it in .shrc or something and ENV=~/.shrc in .profile
'\$' or '#' must appear in PS1 in order to be properly exported as root?
Greetings. This is my first post to the OpenBSD community, so please let me know if I'm in the wrong list, this is just too basic or any other faux pas. Under the default ksh, the default /root/.profile and indeed a completely fresh 4.8 install, adding the following line to /root/.profile does not work as expected: export PS1='$PWD ' The login shell is '/root ', which makes sense to me, but all child shells get the default '# ', despite PS1 being exported. Even more strange, this doesn't happen when PS1 contains '\$' or '#'; it looks like the hash must be in the root prompt. Non-root users are not affected by the equivalent restriction (PS1 may not contain '\$' or '$'). Could anyone point out why this happens? Can this behavior be modified? Coming from a fresh install, there is no /etc/profile or /root/.kshrc. Thank you in advance for your help. Cheers, Ezequiel
Re: '\$' or '#' must appear in PS1 in order to be properly exported as root?
Thank you for your reply, Roberth The default prompt is `$ ' for non-root users, `# ' for root. If ksh is invoked by root and PS1 does not contain a `#' character, the default value will be used even if PS1 already exists in the environment. But isn't PS1 supposed to alter the (default) prompt? It does so for non-root users (even if the new PS1 doesn't contain '$'), and also in other POSIX-compliant shells.
Re: '\$' or '#' must appear in PS1 in order to be properly exported as root?
On Thu, Jan 6, 2011 at 11:18 PM, xSAPPYx xsap...@gmail.com wrote: I think ksh(1) man page has the info, or maybe it is intro(8) Try this: echo export ENV=$HOME/.kshrc ~/.profile echo . /etc/ksh.kshrc ~/.kshrc Yes, in that case the new PS1 value is set by ~/.kshrc, which overrides whatever I did in .profile, but that still leaves me wondering as to why this happens: what other file or setting is being read that changes PS1 back to its default setting?
Re: '\$' or '#' must appear in PS1 in order to be properly exported as root?
On Thu, 6 Jan 2011 23:35:32 +0100 Ezequiel Garzsn garzon.luc...@gmail.com wrote: On Thu, Jan 6, 2011 at 11:18 PM, xSAPPYx xsap...@gmail.com wrote: I think ksh(1) man page has the info, or maybe it is intro(8) Try this: echo export ENV=$HOME/.kshrc ~/.profile echo . /etc/ksh.kshrc ~/.kshrc Yes, in that case the new PS1 value is set by ~/.kshrc, which overrides whatever I did in .profile, but that still leaves me wondering as to why this happens: what other file or setting is being read that changes PS1 back to its default setting? bin/ksh/main.c: safe_prompt = ksheuid ? $ : # ; { 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), \\$ /* setstr can't fail here */ setstr(vp, safe_prompt, KSH_RETURN_ERROR); }
Re: '\$' or '#' must appear in PS1 in order to be properly exported as root?
Wow, that's what I call deep knowledge! Thank you for explaining it, Roberth. Best, Ezequiel On Thu, Jan 6, 2011 at 11:58 PM, roberth rob...@openbsd.pap.st wrote: On Thu, 6 Jan 2011 23:35:32 +0100 Ezequiel Garzsn garzon.luc...@gmail.com wrote: On Thu, Jan 6, 2011 at 11:18 PM, xSAPPYx xsap...@gmail.com wrote: I think ksh(1) man page has the info, or maybe it is intro(8) Try this: echo export ENV=$HOME/.kshrc ~/.profile echo . /etc/ksh.kshrc ~/.kshrc Yes, in that case the new PS1 value is set by ~/.kshrc, which overrides whatever I did in .profile, but that still leaves me wondering as to why this happens: what other file or setting is being read that changes PS1 back to its default setting? bin/ksh/main.c: safe_prompt = ksheuid ? $ : # ; { 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), \\$ /* setstr can't fail here */ setstr(vp, safe_prompt, KSH_RETURN_ERROR); }