`export PS1='value'` 不会传播到 root 的 (Korn) 子 shell?
请考虑以下 /root/.profile:
export PS1=value1
export x=value2
为什么登录 shell 显示预期的提示(并且 $x 作为 value2),而子 shell 一直将 $x 显示为 value2 而 $PS1 显示为“#”?以防万一,我正在 OpenBSD 下尝试这个。
[是的,我知道...如果我不知道这一点,我到底在用 OpenBSD 做什么?只是在一个孤立的、绝对非生产的虚拟机中玩耍......
Please consider the following /root/.profile:
export PS1=value1
export x=value2
How come the login shell shows the expected prompt (and $x as value2), while the subshells keep showing $x as value2 but $PS1 as '#'? Just in case, I'm trying this under OpenBSD.
[Yeah, I know... What on earth am I doing with OpenBSD if I don't know this? Just toying... in an isolated, most definitely non-production VM =).]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
因为你的子 shell 正在获取重置 PS1 的东西。
要调试此问题,请尝试
ksh -x
。如果这没有帮助,您可以尝试在strace< 中运行
ksh
/code> 或等效的系统调用跟踪工具。
Because your subshells are sourcing something that's resetting PS1.
To debug this, try
ksh -x
. If that doesn't help, you could try runningksh
instrace
or an equivalent system call tracing tool.如果有人感兴趣,终于有人在 OpenBSD 邮件列表中解释了这一点< /a>.这种行为实际上是 OpenBSD 中所期望的,正如 /usr/src/bin/ksh/main.c:
In case anybody is interested, somebody finally explained this in an OpenBSD mailing list. This behavior is actually expected in OpenBSD, as explained in a comment inside /usr/src/bin/ksh/main.c:
检查以下文件是否存在恶意 PS1 分配。
该手册页中可能有一个拼写错误,它的意思可能是:
$HOME/.kshrc
Check the following files for rogue PS1 assignments.
There may be a typo in that manpage, it probably meant to say:
$HOME/.kshrc