9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] environment + functions
@ 2008-10-07 18:31 Rudolf Sykora
  2008-10-07 18:33 ` erik quanstrom
  2008-10-07 18:52 ` andrey mirtchovski
  0 siblings, 2 replies; 10+ messages in thread
From: Rudolf Sykora @ 2008-10-07 18:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 320 bytes --]

Hello,

why after creating a function with

fn my_func_name { something }

and removing this function with

fn my_func_name

a file (though of zero size) exists in /env?

(If I create a lot of functions and then want them be removed, I find a lot
of for-me-uninteresting files in /env...)

Thanks,
Ruda

[-- Attachment #2: Type: text/html, Size: 380 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [9fans] environment + functions
@ 2008-10-08 11:35 erik quanstrom
  0 siblings, 0 replies; 10+ messages in thread
From: erik quanstrom @ 2008-10-08 11:35 UTC (permalink / raw)
  To: rudolf.sykora, 9fans

> > it's done this way, i believe, to ensure that two rc shells running in
> > the same namespaces do not step all over each others' environments. if
> > you simply run 'rfork e' before you experiment with all those
> > functions you won't see the empty files anywhere.
>
> Sorry, but I don't understand... Could you give me some example?

; i=0
; @{i=1; sleep 2; echo $i} & @{i=2; sleep 1; echo $i} ; wait
2
1
; ; cat /env/i
0;

> (I was playing with this to have a prompt that reflects the last part of my
> current directory. Following the example of setting fn term% { $*} I,
> whenever I change a directory, define a similar function with an appropriate
> name. When I change the directory again I do the same for the new one, but
> also want to get rid of the old one... -- actually in the opposite order.)

sounds complicated.  why do you need to define a function for each new
directory?  the prompt trick is sneaky.  it relies on the space.  why not
just move the space and make the thing that required a new function
an argument to a fixed function?

fn $sysname: {
}
fn cd{
	builtin cd $*
	awd
	prompt=($sysname:' '`{basename `{pwd}}^'; ' '')
}

or you can go minimilst bourne and have

fn : {
}
fn cd{
	bultin cd $*
	awd
	prompt=(': '`{basename `{pwd}}^'; ' '')
}

- erik



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

end of thread, other threads:[~2008-10-08 19:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-07 18:31 [9fans] environment + functions Rudolf Sykora
2008-10-07 18:33 ` erik quanstrom
2008-10-07 18:52 ` andrey mirtchovski
2008-10-08 10:58   ` Rudolf Sykora
2008-10-08 18:46     ` Pietro Gagliardi
2008-10-08 18:52       ` Rudolf Sykora
2008-10-08 19:12         ` erik quanstrom
2008-10-08 19:16         ` Pietro Gagliardi
2008-10-08 19:25           ` Rudolf Sykora
2008-10-08 11:35 erik quanstrom

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).