我正在尝试调试bash在Linux登录初始化时的作用。我已经读过“ bash -x”将使bash打印出正在执行的操作,但不会像“ set -x”那样在源文件中打印命令。我不能使用“ set -x”,因为初始化会在调用它之前运行。“ bash -x”似乎可以在OS X上正常运行,但这可能是由于bash版本所致。
Linux:3.2.25
OS X:3.2.48
这是Linux上非递归行为的摘录:
bash -l -x -c 'echo 1'
# ... snip ...
+ for i in '/etc/profile.d/*.sh'
+ '[' -r /etc/profile.d/vim.sh ']'
+ '[' '' ']'
+ . /etc/profile.d/vim.sh
+ for i in '/etc/profile.d/*.sh'
+ '[' -r /etc/profile.d/which-2.sh ']'
+ '[' '' ']'
+ . /etc/profile.d/which-2.sh
# ... snip ...
请注意/etc/profile.d/vim.sh的来源,但不会显示其命令。有没有升级的解决方法?这是由版本差异引起的吗?