rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: gjv%atlas%cesar@crbca1.SINet.SLB.COM
To: rc%hawkwind.utcs.toronto.edu%m_internet%m_mailnow%hermes.DECnet@cesar.
Subject: Something for the FAQ ?
Date: Tue, 14 Sep 1993 05:56:23 -0400	[thread overview]
Message-ID: <9309141000.AA20951@SINet.SLB.COM> (raw)

Hello all,

I was just wondering, is there a collection of useful functions somewhere?
I found some in the FAQ and in the mail list archive of course, but I
assume that there are a lot more useful things out there, which could
be made more accessible when added to the FAQ for example. What made me
think of this is the following:

I'm using the prompt function for the initialisation of interactive
subshells, but this makes $status unusable if you aren't careful.
I came up with the following, which seems to work nicely. (init
is a function to initialise the subshell).

fn prompt  {
    s=$status {
        if ( ! ~ $ipid $pid ) {

            # one time call to init_shell(), initialises interactive subshell
        return $s

You can't simply save&restore $status, since the assignment to $status
itself would change the status.

I also wrote the next functions in order to be able
to clean up my $path (removing duplicates), or to remove an entry.

# remove(varname, elt) removes elt from $varname
fn remove {
    vn=$1 e=$2  o=() *=$$vn{
        while( ! ~ $#* 0)
           ~ $*(1) $e || o=($o $*(1) )

# clean(varname) removes all double entries from $varname, keeping the first
fn clean {
    vn=$1 o=() *=$$vn{
        while( ! ~ $#* 0)
            ~ $o $*(1) || o=($o $*(1) )

# example
clean path
remove path /usr/bin

The only thing to add is the support for ':' separated lists,
list-equivalent like PATH/path.

Thought it might be useful to have this kind of stuff in a place where
it can easily be found, like the FAQ for example.


J.G. Vons   E-Mail: vons@cesar.crbca1.sinet.slb.com

                 reply	other threads:[~1993-09-14  9:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

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

  git send-email \
    --in-reply-to=9309141000.AA20951@SINet.SLB.COM \
    --to=gjv%atlas%cesar@crbca1.sinet.slb.com \
    --cc=rc%hawkwind.utcs.toronto.edu%m_internet%m_mailnow%hermes.DECnet@cesar.sedalia.sinet.slb.com \
    --cc=vons@cesar.crbca1.sinet.slb.com \


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