bug-bash
[Top][All Lists]
Advanced

[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: Sun, 03 Jan 2010 17:23:26 -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/3/10 8:02 AM, Leonid Evdokimov wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: i686
> OS: linux-gnu
> Compiler: i686-pc-linux-gnu-gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
> -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  
> -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
>  -DSTANDARD_UTILS_PATH='/bin:/usr/bin:/sbin:/usr/sbin' 
> -DSYS_BASHRC='/etc/bash/bashrc' -DSYS_BASH_LOGOUT='/etc/bash/bash_logout' 
> -DNON_INTERACTIVE_LOGIN_SHELLS -DSSH_SOURCE_BASHRC -O2 -march=pentium-m -pipe
> uname output: Linux thinkpad 2.6.31-gentoo-r6 #2 PREEMPT Fri Dec 18 13:16:52 
> OMST 2009 i686 Intel(R) Pentium(R) M processor 1600MHz GenuineIntel GNU/Linux
> Machine Type: i686-pc-linux-gnu
> 
> Bash Version: 4.0
> Patch Level: 35
> Release Status: release
> 
> Description:
> 
> `pwd` may return incorrect value, moreover, `pwd` output differs from /bin/pwd
> output.
> 
> Repeat-By:
> 
> darkk@thinkpad ~ $ cd foo
> darkk@thinkpad ~/foo $ touch foo-files
> darkk@thinkpad ~/foo $ ls
> foo-files
> darkk@thinkpad ~/foo $ mv ~/foo ~/bar
> darkk@thinkpad ~/foo $ ls
> foo-files
> darkk@thinkpad ~/foo $ echo $PWD
> /home/darkk/foo
> darkk@thinkpad ~/foo $ pwd
> /home/darkk/foo
> darkk@thinkpad ~/foo $ /bin/pwd
> /home/darkk/bar
> darkk@thinkpad ~/foo $ cd .
> darkk@thinkpad ~/bar $ echo $PWD
> /home/darkk/bar
> darkk@thinkpad ~/bar $ pwd
> /home/darkk/bar
> darkk@thinkpad ~/bar $ /bin/pwd
> /home/darkk/bar
> 
> Strace of this bash session may be found at
> http://darkk.net.ru/tmp/bash-pwd-bug.strace.log
> 
> Fix:
> 
> This problem may be fixed if bash does not optimise number of getcwd() calls,
> but I'm not sure if the bug is really a _bug_, but not a sort of strange
> feature.

It's not a bug, nor a "strange feature."  Bash maintains a logical view of
the file system and the current directory for cd, pwd, and $PWD, as Posix
specifies.  One of the consequences is that the pathname of the current
directory depends on the path used to reach it.

If you want to see a physical view of the file system, use `cd -P' or
`set -o physical'.

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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]