From: Bruce Perens <bruce@pixar.com>
To: rc@hawkwind.utcs.toronto.edu
Subject: Hacking the history mechanism in rc
Date: Mon, 28 Sep 1992 18:40:46 -0400 [thread overview]
Message-ID: <m0mZTlm-0000rcC@copland.pixar.com> (raw)
-------
I wanted to have a way to implement my own history
mechanism without hacking rc to bits, so I added
a "hook" for an external history mechanism. When my
version of rc is about to process a command line, it
checks to see if the user has defined an rc function
"add_history". If so, it calls the user function with
the command line in $1 . A simple definition of
add_history is:
fn add_history {
echo -n $1 >> /usr/people/bruce/history_file
}
My version is a bit more complicated. It puts the
last command in the window title, etc.
I think this is a good change because:
+ It replaces 15 lines of hard-coded C with four lines.
+ It makes rc more versatile without adding code.
+ It preserves the existing functionality.
I'm also experimenting with a "glob" function. The
function is called before globbing a filename, with a list containing
the arguments. If it recognizes any special characters that
it handles, it calls an external module that expands them
and returns the expanded list. I use this to implement ~name expansion
as in c-shell without adding code to rc. I was inspired by an old Version 6
or Version 7 Unix shell that used an external "glob" program.
I think there is a lot of room for work with "hook" functions.
Through them, rc can be made a lot more versatile without adding
code to rc itself.
Bruce Perens
reply other threads:[~1992-09-28 22:41 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=m0mZTlm-0000rcC@copland.pixar.com \
--to=bruce@pixar.com \
--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).