9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: rudolf.sykora@gmail.com, 9fans@9fans.net
Subject: Re: [9fans] environment + functions
Date: Wed,  8 Oct 2008 07:35:23 -0400	[thread overview]
Message-ID: <08e519c557d58126a26246dad433d182@quanstro.net> (raw)

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



             reply	other threads:[~2008-10-08 11:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-08 11:35 erik quanstrom [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-10-07 18:31 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=08e519c557d58126a26246dad433d182@quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    --cc=rudolf.sykora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).