tags:

views:

21

answers:

1

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 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.

+1  A: 

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)).

Dennis Williamson
Anyone know why this gets set differently in --posix mode?
Chris Quenelle