我想为自己\xe2\x80\x94和许多其他用户\xe2\x80\x94创建一个脚本,该脚本将配置使用特定版本工具集\xe2\x80\xa6的环境,然后使用该脚本打开一个交互式shell环境。
\n\n似乎发生的情况是~/.bashrc执行了各种用户初始化脚本 ( ) 并破坏了部分设置。
许多用户(包括我自己)在其 \xe2\x80\xa6 中配置了默认版本的工具~/.bashrc,并希望保持这种状态。
我为其制作此脚本的备用版本仅在一小部分时间内使用。
\n\n我已经尝试过以下方法:
\n\nsetup the environment\nbash\n # runs ~/.bashrc and breaks the setup\n\nbash -i\n # runs ~/.bashrc and breaks the setup\n\nbash --rcfile <(echo echo in subshell... $PATH)\n the displayed $PATH is correct - but I immediately return\n to the parent (no longer a subshell - not interactive)\n\nbash --rcfile -i <echo echo in subshell... $PATH)\n the displayed $PATH is correct - but I immediately return\n to the parent (not a subshell)\nRun Code Online (Sandbox Code Playgroud)\n\n我们不想\xe2\x80\x99 想要。source该文件我已经可以做到这一点:我们希望能够exit回到以前的环境。
那么\xe2\x80\xa6 我如何获得一个与父 shell 具有完全相同的当前环境的交互式 Bash 子 shell?
\n\n无论如何,我希望它能够在 RedHat 和 Ubuntu 环境中运行。
\nbash --norc -i\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n\n\n
--norc~/.bashrc\n 不要\xe2\x80\x99t在交互式 shell 中读取初始化文件。[\xe2\x80\xa6]
有一个类似的选项(但对于非登录 shell 不需要它):
\n\n\n\n\n\n
--noprofile
\n 不要\xe2\x80\x99t 加载系统范围的启动文件/etc/profile或任何个人初始化文件~/.bash_profile、~/.bash_login或~/.profile当 Bash 作为登录 shell 调用时。
(来源)
\n\n如果调用bash是脚本执行的最后一件事,您可以exec:
exec bash --norc -i\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1595 次 |
| 最近记录: |