From: culliton@srg.srg.af.mil (Tom Culliton x2278)
To: rc@hawkwind.utcs.toronto.edu
Subject: A (new and improved) Xmas toy
Date: Wed, 22 Dec 1993 17:49:06 -0500 [thread overview]
Message-ID: <9312221749.aa18791@ceres.srg.af.mil> (raw)
# Amazing what an extra half hour of thought will do to improve a piece
# of code. I was fretting about the size of the function, because SCO
# Unix has limited environment space and managed to shave its size a bit
# and make it a little cleaner.
fn dirs { echo $D }
fn cd {
if (! ~ $#* [01])
{
echo too many arguments
return 1
}
switch ($1)
{
case - # shorthand for -1
cd $D(1) # recursion
case -[1-9] -[1-9][0-9] # 1 -> 99 are valid
cd $D(`{echo $1 | cut -c2-}) # recursion
case -[0-9]* # catch dumb stuff
echo bad numeric argument
return 1
case * # also handles no args case
d=$D i=() {
D = `{/bin/pwd} # MRU moves to front
for (i in $d) # and eliminate duplicates
if (! ~ $D $i)
D = ($D $i)
builtin cd $1 # actually go there
# and fix the prompt
}
}
}
reply other threads:[~1993-12-22 23:20 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:
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=9312221749.aa18791@ceres.srg.af.mil \
--to=culliton@srg.srg.af.mil \
--cc=rc@hawkwind.utcs.toronto.edu \
/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).