庆典似乎通过一个符号链接访问时忽略BASH_ENV [英] bash seems to ignore BASH_ENV when accessed through a symlink

查看:147
本文介绍了庆典似乎通过一个符号链接访问时忽略BASH_ENV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 / bin中已成立了这样的UNIX环境中工作:

I'm working in a UNIX environment where /bin has been set up like this:

-rwxr-xr-x  1 root root 617144 Nov 19  2009 bash
lrwxrwxrwx  1 root root      4 Nov 23  2010 sh -> bash

在我的环境我已经设置 $ BASH_ENV 来指向我的本地.bashrc中:

In my environment I have set $BASH_ENV to point to my local .bashrc:

env | grep BASH
BASH_ENV=/home/users/atomicpirate/.bashrc

此外,.bashrc中作为其第一行呼应的.bashrc READ

我希望/ bin / sh的和/斌/ bash的表现与此设置完全一样......但他们不这样做:

I would expect /bin/sh and /bin/bash to behave exactly the same with this setup...but they don't:

/bin/bash -c 'echo $BASH_ENV'
BASHRC READ
/home/users/atomicpirate/.bashrc

/bin/sh -c 'echo $BASH_ENV'
/home/users/atomicpirate/.bashrc

在第二种情况下,是的.bashrc不读。任何想法,为什么会这样呢?这似乎是符号链接是打破$ BASH_ENV的预期行为。

In the second case, .bashrc is NOT read. Any idea why this would be the case? It seems like the symlink is breaking the expected behavior of $BASH_ENV.

推荐答案

bash的手册页:

如果bash以名称sh启动,它试图模仿的启动行为
  sh历史尽可能接近,
  而符合
  POSIX标准。

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.

请注意,当交互shell中,在方式现代化 SH 使用 $ ENV 类似的方式运行庆典使用 $ BASH_ENV 。此行为是由模仿庆典以及

Note that when run as interactive shell, modern sh uses $ENV in a manner similar to the way bash uses $BASH_ENV. This behavior is mimicked by bash as well.

这篇关于庆典似乎通过一个符号链接访问时忽略BASH_ENV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆