9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] environment variables bevanving weird
@ 2012-06-08 23:02 Friedrich Psiorz
  2012-06-08 23:13 ` vrtra
  2012-06-08 23:13 ` Federico Benavento
  0 siblings, 2 replies; 3+ messages in thread
From: Friedrich Psiorz @ 2012-06-08 23:02 UTC (permalink / raw)
  To: 9fans

hi! I'm new to Plan 9 and I don't understand this behavior:

I wrote a program that basically just does
putenv("foo", "bar");

After running it,
echo $foo
prints just an empty line, while
cat /env/foo
prints bar. Can anyone explain?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] environment variables bevanving weird
  2012-06-08 23:02 [9fans] environment variables bevanving weird Friedrich Psiorz
@ 2012-06-08 23:13 ` vrtra
  2012-06-08 23:13 ` Federico Benavento
  1 sibling, 0 replies; 3+ messages in thread
From: vrtra @ 2012-06-08 23:13 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> hi! I'm new to Plan 9 and I don't understand this behavior:
>
> I wrote a program that basically just does
> putenv("foo", "bar");
>
> After running it,
> echo $foo
> prints just an empty line, while
> cat /env/foo
> prints bar. Can anyone explain?

I asked a somewhat same question a month back
http://9fans.net/archive/2012/05/281

The reason seems to be that while creating a variable foo
in rc is immediately reflected to /env/foo, the reverse is
not true. That is, creating a new file under /env/baz does
not update the current rc instance with a new variable $baz

So in this case, putenv is actually writing to /env/foo,
and it would be visible only if you start a new rc
instance. (or just read from the same file.)

v



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] environment variables bevanving weird
  2012-06-08 23:02 [9fans] environment variables bevanving weird Friedrich Psiorz
  2012-06-08 23:13 ` vrtra
@ 2012-06-08 23:13 ` Federico Benavento
  1 sibling, 0 replies; 3+ messages in thread
From: Federico Benavento @ 2012-06-08 23:13 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

see env(3), basically the rfork flags affect it. check the man page.

On Jun 8, 2012, at 8:02 PM, Friedrich Psiorz wrote:

> hi! I'm new to Plan 9 and I don't understand this behavior:
>
> I wrote a program that basically just does
> putenv("foo", "bar");
>
> After running it,
> echo $foo
> prints just an empty line, while
> cat /env/foo
> prints bar. Can anyone explain?
>

---
Federico Benavento
benavento@gmail.com






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-08 23:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-08 23:02 [9fans] environment variables bevanving weird Friedrich Psiorz
2012-06-08 23:13 ` vrtra
2012-06-08 23:13 ` Federico Benavento

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).