On Tue, Aug 18, 2009 at 1:02 PM, David Green<david.gr...@telus.net> wrote:
> On 2009-Aug-18, at 3:12 am, Jan Ingvoldstad wrote:
>>
>> It may seem cool, but I don't like secondary effects like that. They break
>> the principle of least surprise.
>
> It doesn't seem that surprising to me, especially after seeing the docs the
> first time.  Are there environments where you can set a variable like $*CWD
> and it doesn't do something like chdir?

Yes, and that's normal and expected behaviour.

viking...@shell:~$ uname -a
Linux shell 2.4.37.5 #1 Sun Aug 16 12:47:03 CEST 2009 i686 unknown
unknown GNU/Linux
viking...@shell:~$ bash --version
GNU bash, version 2.05b.0(1)-release (i486-slackware-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.
viking...@shell:~$ mkdir test
viking...@shell:~$ touch test/testfile
viking...@shell:~$ cd test
viking...@shell:~/test$ ls
testfile
viking...@shell:~/test$ pwd
/home/1/v/vikingmud/test
viking...@shell:~/test$ echo $PWD
/home/1/v/vikingmud/test
viking...@shell:~/test$ PWD="foo/notreallyadirectory"
viking...@shell:foo/notreallyadirectory$ ls
testfile
viking...@shell:foo/notreallyadirectory$ pwd
/home/1/v/vikingmud/test
viking...@shell:foo/notreallyadirectory$ echo $PWD
foo/notreallyadirectory


j...@krakas ~ >uname -a
Darwin krakas.ELIDED 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15
16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386
j...@krakas ~ >bash --version
GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0)
Copyright (C) 2005 Free Software Foundation, Inc.
j...@krakas ~ >mkdir test
j...@krakas ~ >touch test/testfile
j...@krakas ~ >cd test
j...@krakas ~/test >ls
testfile
j...@krakas ~/test >pwd
/Users/jani/test
j...@krakas ~/test >echo $PWD
/Users/jani/test
j...@krakas ~/test >PWD="foo/notreallyadirectory"
j...@krakas foo/notreallyadirectory >ls
testfile
j...@krakas foo/notreallyadirectory >pwd
/Users/jani/test
j...@krakas foo/notreallyadirectory >echo $PWD
foo/notreallyadirectory

-- 
Jan

Reply via email to