From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 24 Nov 2009 11:29:44 +0000 Message-ID: From: roger peppe To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] environment variables Topicbox-Message-UUID: 9f33b288-ead5-11e9-9d60-3106f5b1d025 2009/11/23 Rudolf Sykora : > Hello, > > If I have an rc script and I don't specify any rfork in it, then the > namespace and the environment should be shared. > So, having an 'a' script > > #!/bin/rc > a =3D hello > cd c =C2=A0 #later on... > > and a 'b' script: > > #!/bin/rc > a > echo $a > > and running the 'b' script, I'd expect that the 'a' variable would be set= to > 'hello' and written out. But it does not work like that, thanks to some > caching or what. How should the 'b' script, or whatever, be corrected so > that it work? yes, rc caches the values of its environment variables to avoid reading all the values after every command is run. if you want to re-get the value of an environment variable, you can do: ifs=3D() var=3D`{cat /env/var} > Further, I am now a bit puzzled about whose property the 'current directo= ry' > is. Why isn't the directory changed to 'c' after runing either the 'a' or > 'b' script? Is this always a local property of each shell? in plan 9 the current working directory is per-process (inferno is different here - it's part of the current name space).