🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
3 messages
3 total messages Started by RoseAnn Ammendolea Fri, 19 Oct 1990 16:57
Questions about rewriting the History function.
#1066
Author: RoseAnn Ammendolea
Date: Fri, 19 Oct 1990 16:57
13 lines
1614 bytes
	I am working on a senior project to rewrite the history function for    UNIX.  My goal is to have the new history functon work like it does in MS_DOS.
i.e. I want to be able to call up past commands and edit them by using the 
control <hjkl> characters.  Additionally, I would like to write this as a stand alone program so that I do not have to rewrite the shell.
	The main approach I will use will be to store the previous commands in alinked list.  My only problem is that I do not know how to intercept the commandonce it has been entered, before it gets executed.  Likewise, I do ont know how to execute the command once I have retreived it form the list. i.e. I want to   display the command for possible editting and execute it when the carriage
return is pressed.
	If there is anyone out there that has some ideas or suggestions, they   would be greatly appreciated. Also if anyone knows where I might be able to find the source code for the present HISTORY function or the R function I would like to know so I can look at it and gain some insight to my project.

P.S. Please do not send replys to posters address use the address in the 
     reply-to header.


Thank You.			Mark
Re: Questions about rewriting the History function.
#1076
Author: Bill Stewart 201-949-0705 erebus...
Date: Sun, 21 Oct 1990 01:02
42 lines
2807 bytes
In article <1990Oct19.165721.7584@polyof.poly.edu>, roseann@polyof.poly.edu,
(RoseAnn Ammendolea) (or Marc someone using her account?) writes:
] I am working on a senior project to rewrite the history function for UNIX.
] My goal is to have the new history function work like it does in
] MS_DOS.  i.e. I want to be able to call up past commands and edit them
] by using the control <hjkl> characters.  Additionally, I would like to
] write this as a stand alone program so that I do not have to rewrite the shell.

The main problem is that UNIX doesn't process or remember the command lines,
(except to the crude extent that the accounting system does) -
it's all done by the shell.  The commands you type are simply input
to the shell, which does any interpretation, and fork()/exec()s the
command if it's a "real" command, or just does it if it's a shell builtin.

Depending on what shell you use, it may or may not have a history
capability, and that history may be stored in a file or in memory.
If it's in a file, it may not be absolutely up-to-date.
You'll have to play around with shells you like, and you really need source.

The old Bourne shell (/bin/sh) doesn't do history.
The C shell does, with the ugly !! command-based interface.
The Korn shell (ksh) does history, stores it in a file, and gives
	you an editor-interface as well as a command-based interface.
Various intellectual derivatives like BASH and tcsh are similar.
The 9th edition shell gave you something lean, mean, and clean, as always.
The adventure shell doesn't have history, but it has xyzzy. :-)

MS-DOS itself doesn't have a 'history' command.  The F1 and F3 keys
let you get the most recent command, unless it's been trashed;
I think this is managed by command.com rather than DOS.
There are a couple of history commands running around, including
HISTORY and ANARKEY; don't know if any of them come with source.

The other good thing about VMS, besides HELP, was command editing.
It probably only worked for VT100 terminals, but it was there and easy.

			Good luck
-- 
					Thanks; Bill
# Bill Stewart 908-949-0705 erebus.att.com!wcs AT&T Bell Labs 4M-312 Holmdel NJ
Government is like an elephant on drugs: It's very confused, makes lots of noise,
can't do anything well, stomps on anyone in its way, and it sure eats a lot.
Re: Questions about rewriting the History function.
#1082
Author: Alex Martelli
Date: Wed, 24 Oct 1990 08:01
41 lines
2769 bytes
wcs@cbnewsh.att.com (Bill Stewart 201-949-0705 erebus.att.com!wcs) writes:
	...
>The main problem is that UNIX doesn't process or remember the command lines,

It doesn't, but then again, it MIGHT!  There's a line-discipline called
CLED (Command Line Editing Discipline?), that was posted to some source
newsgroup within the last year or so, to do just that - history and
reasonable editing, NOT just erase and kill, for any process reading
/dev/tty in canonical mode.  I have not been able to install it, but the
concept appears to be sound.

>You'll have to play around with shells you like, and you really need source.

I believe source for a sh lookalike was posted to some source group too,
maybe comp.sources.unix in or around volume 19; it may be easier to
work with than something more complex like ksh, yashell, etc.
Source for a VERY bare-bones subset of sh is in Rochkind's wonderful
book "Advanced Unix Programming" (if you haven't mastered the concepts
it displays, you're not a Unix programmer; if you have, you owe it to
yourself to read the book anyway - it's an enjoyable experience, on a
par with other classics in technical literature such as "The Unix
Programming Environment" and "The C Programming Language").
Given Rochkind's didactical purposes, this subset may be even better
than the full sh in volume 19, IFF the exercise is in a school setting;
for real-world purposes, of course, featuritis may be needed.

If you want to *redesign* a Unix shell, rather than starting from
available sources, look at the specs for "rc", Plan 9's shell, in the
proceedings of the UKUUG conference held in London last July; rc's
sources MIGHT even be available at some time in the future, but I'm told
not to hold my breath while AT&T's accountants figure out if this would
be A Good Thing - on the other hand, the specs and rationale ARE there
right now, and a good design it appears to be (I don't know what
"look-and-feel" intellectual-property laws and strictures might apply,
of course).

-- 
Alex Martelli - CAD.LAB s.p.a., v. Stalingrado 45, Bologna, Italia
Email: (work:) staff@cadlab.sublink.org, (home:) alex@am.sublink.org
Phone: (work:) ++39 (51) 371099, (home:) ++39 (51) 250434; 
Fax: ++39 (51) 366964 (work only; any time of day or night).
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads