[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: $(pwd) != $(/bin/pwd)
From: |
Chet Ramey |
Subject: |
Re: $(pwd) != $(/bin/pwd) |
Date: |
Wed, 06 Jan 2010 21:19:36 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 |
On 1/6/10 1:46 PM, Stephane CHAZELAS wrote:
> 2010-01-05 16:40:50 -0500, Chet Ramey:
>>> Well, if I read
>>> http://www.opengroup.org/onlinepubs/9699919799/utilities/pwd.html
>>> correctly, bash pwd should output /home/darkk/bar in that case
>>> as $PWD does *not* contain an absolute path to the current
>>> directory.
>>
>> Bash notices this when running in posix mode, and recanonicalizes the
>> pathname. By default, it does not.
>>
>>> Having said that, ksh93, ash and zsh behave like bash, pdksh and
>>> its derivatives being the only ones that behave as POSIX
>>> requires.
>>
>> Bash behaves as Posix requires when running in posix mode. When it's not,
>> it does the same thing as other shells.
> [...]
>
> OK, that's fine then.
>
> Any reason for not doing it when not in POSIX mode? Could the
> output of pwd changing while no change of directory has been
> made ever be more of a problem than $(pwd) not reflecting the
> current directory.
Not really, other than the potentially expensive directory traversal to
do a couple of stat(2) calls. I don't really think this is much of a
problem at all. How often does the directory change out from under a
shell process, after which it calls pwd?
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/