开发者

Why does bash in posix mode fail to chase my symlinks?

I'm seeing weird behavior when I run "ssh " to a Linux system. I tracked it down part way to a difference in bash when started in posix mode.

% bash --posix
% ln -s /tmp mytmp
% cd mytmp
% pwd
/home/user/mytmp

The bash man page has these items under posix mode:

--> When the cd builtin is invoked in logical mode, and the pathname constructed from $PWD and the directory name supplied as an argument does not refer to an existing directory, cd will fail instead of falling back to physical mode.

--> When the pwd builtin is supplied the -P option, it resets $PWD to a pathname containing no symlinks.

--> The pwd builtin verifies that the开发者_如何学Python value it prints is the same as the current directory, even if it is not asked to check the file system with the -P option.

none of those sounds exactly like what I'm seeing.

I don't seem to have any special PWD-related variables set in start up files. I know that --posix controls which start up files are used.

Is there a variable that explicitly controls like kind of symlink chasing?

I can think of several ways to "undo" this effect, but I need to know why it's happening.

I'm using ssh to run make, and then make is using pwd, and THAT pwd is coming up with the wrong answer. It must be taking it directly from an ENV setting. I'd like to find some docs someplace about what's going on.


If you do set -o | grep physical and that's set to on, it's the same as -P.

To turn on:

set -o physical

or

set -P

to turn off:

set +o physical

or

set +P

Check to see if cd or pwd are redefined:

type -a cd pwd

There are circumstances where pwd and $PWD won't be in sync. When in doubt, use pwd (as in `$(pwd)).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜