From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SINet.SLB.COM ([163.185.18.1]) by hawkwind.utcs.toronto.edu with SMTP id <2755>; Tue, 14 Sep 1993 05:57:22 -0400 Received: from sndrtr.psi by SINet.SLB.COM id AA20951; Tue, 14 Sep 93 10:00:10 GMT From: gjv%atlas%cesar@crbca1.SINet.SLB.COM Message-Id: <9309141000.AA20951@SINet.SLB.COM> Apparently-To: "hawkwind.utcs.toronto.edu::rc" X-Vms-From: PSI%CRBCA1::CESAR::ATLAS::"gjv" X-Vms-To: HERMES::M_MAILNOW::M_INTERNET::HAWKWIND.UTCS.TORONTO.EDU::RC Received: by DniMail (v1.0); Tue Sep 14 11:56:35 1993 MET DST Received: from pyxis by atlas.atlasnis (4.1/SMI-4.1-DNI) id AA26978; Tue, 14 Sep 93 11:56:18 +0200 To: rc%hawkwind.utcs.toronto.edu%m_internet%m_mailnow%hermes.DECnet@cesar. sedalia.sinet.slb.com Reply-To: vons@cesar.crbca1.sinet.slb.com Subject: Something for the FAQ ? Date: Tue, 14 Sep 1993 05:56:23 -0400 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 ) { ipid=$pid # one time call to init_shell(), initialises interactive subshell init_shell } 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) ) shift } $vn=$o } } # clean(varname) removes all double entries from $varname, keeping the first fn clean { vn=$1 o=() *=$$vn{ while( ! ~ $#* 0) { ~ $o $*(1) || o=($o $*(1) ) shift } $vn=$o } } # example clean path remove path /usr/bin The only thing to add is the support for ':' separated lists, like MANPATH,FONTPATH,HELPPATH,LD_LIBRARY_PATH which don't have a 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. Gert-Jan --------------------------------------------------- J.G. Vons E-Mail: vons@cesar.crbca1.sinet.slb.com