* Hacking the history mechanism in rc
@ 1992-09-28 22:40 Bruce Perens
0 siblings, 0 replies; only message in thread
From: Bruce Perens @ 1992-09-28 22:40 UTC (permalink / raw)
To: rc
-------
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1992-09-28 22:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-09-28 22:40 Hacking the history mechanism in rc Bruce Perens
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).