|
发表于 2008-11-26 22:26:01
|
显示全部楼层
首先,你需要明白什么叫[color="Red"]登录shell,什么是[color="Red"]非登录shell,后者又区分[color="Red"]交互式shell和[color="Red"]非交互式shell,而前者一般都是交互式的。
然后阅读bash手册页,看看这三种区别
- 交互式登录shell
- 交互式非登录shell
- 非交互式shell
分别会读取哪些shell配置文件:那么,你首先可以排除掉~/.profile,因为默认情况下几乎所有的终端仿真器都是执行非登录式交互式shell,而~/.profile只有登录式shell才会读取。
然后,从你的$SHELL输出看出,你在使用/bin/sh而非/bin/bash,虽然实际上都是bash,但是...还是看手册:- If bash is invoked with the name sh, it tries to mimic the startup
- behavior of historical versions of sh as closely as possible, while
- conforming to the POSIX standard as well. When invoked as an interac-
- tive login shell, or a non-interactive shell with the --login option,
- it first attempts to read and execute commands from /etc/profile and
- ~/.profile, in that order. The --noprofile option may be used to
- inhibit this behavior. When invoked as an interactive shell with the
- name sh, bash looks for the variable ENV, expands its value if it is
- defined, and uses the expanded value as the name of a file to read and
- execute. Since a shell invoked as sh does not attempt to read and exe-
- cute commands from any other startup files, the --rcfile option has no
- effect. A non-interactive shell invoked with the name sh does not
- attempt to read any other startup files. When invoked as sh, bash
- enters posix mode after the startup files are read.
复制代码
终端仿真器和伪终端...除非你想深入了解,那就建议买《UNIX环境高级编程》或者《高级UNIX编程》或者《UNIX系统编程》,否则就不需要太纠结... |
|