Thread View: comp.unix.shell
7 messages
7 total messages
Started by RoseAnn Ammendolea
Fri, 19 Oct 1990 17:01
Questions about rewriting the History function.
Author: RoseAnn Ammendolea
Date: Fri, 19 Oct 1990 17:01
Date: Fri, 19 Oct 1990 17:01
13 lines
1714 bytes
1714 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.
Author: Vadim G. Antonov
Date: Sat, 20 Oct 1990 14:30
Date: Sat, 20 Oct 1990 14:30
37 lines
2304 bytes
2304 bytes
In article <1990Oct19.170143.7674@polyof.poly.edu> mhoffman@george.poly.edu writes: > > 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. I've written the such program (it's about 50 lines :-) sorry but I haven't it handy. To use it one should add the following alias to .cshrc: alias r 'eval `history | redo`' so if you want to edit previous lines you should enter the command r. This program was died because we (Sergey Ryzhkov & I) have made our own revision of csh with builtin line-editing facility. (So there is no need to enter commands to go to editing mode). It was not so simple because Unix tty drivers handle modes switching in the very *ugly* way - I've spent a week trying to make a sequence allowing do it without flushing characters. (Oh I use to type commands *before* a prompt appears :-). Another problem was the proper processing of ^Z and ^Y - some our ttys used this chars (as well as ^Q and ^S) in escape sequences. We decided to read all characters as ordinary ones and process it in program - and I had to hack tty driver to allow TIOCSTART and TIOCSTOP to work with ordinary ttys as well as with ptys. Problem with ^Z/^Y was solved by non-trivial hack in csh's internals. Anyway it was done and works under DEMOS 2.2. Thus I suggest you to do the thing in the first way, it's much simplier and practically as suitable as the second for an endluser. Vadim Antonov DEMOS, Moscow, USSR
Re: Questions about rewriting the History function.
Author: Shiping Zhang
Date: Sun, 21 Oct 1990 20:19
Date: Sun, 21 Oct 1990 20:19
9 lines
1092 bytes
1092 bytes
In article <1990Oct19.170143.7674@polyof.poly.edu> mhoffman@george.poly.edu writes: > 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. We have a shell script which lets you edit history commands before they are reexecuted. -ping
Re: Questions about rewriting the History function.
Author: Oscar Herrera
Date: Mon, 22 Oct 1990 13:59
Date: Mon, 22 Oct 1990 13:59
9 lines
1012 bytes
1012 bytes
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. Thank You. Mark ---------- If your version of un*x supports the command script, you may extract the history from the script output file. script is a terminal session recorder.
Re: Questions about rewriting the History function.
Author: Peter McLain
Date: Thu, 25 Oct 1990 23:12
Date: Thu, 25 Oct 1990 23:12
14 lines
951 bytes
951 bytes
>which may be ugly, but is quite convenient. But ksh won't do asynch job
>notification, key rebinding, or spelling correction, so I'm stuck with an
>abomination of a shell.
You can get asynch job notification in ksh88 by doing:
trap "jobs -n" CHLD
Peter McLain Hewlett-Packard
3404 East Harmony Road
pbm%hpfclj@hplabs.HP.COM Fort Collins
UUCP: hplabs!hpfcla!pbm CO 80525-9599
Bad trap (Re: Questions about rewriting the History function.)
Author: Blair P. Houghton
Date: Sat, 27 Oct 1990 06:01
Date: Sat, 27 Oct 1990 06:01
17 lines
986 bytes
986 bytes
In article <32120001@hpfcdc.HP.COM> pbm@hpfcdc.HP.COM (Peter McLain) writes: > You can get asynch job notification in ksh88 by doing: > > trap "jobs -n" CHLD Which reminds me; why, in sh(1), does trap 'echo foo' 18 (where signal 18 is SIGTSTP) give a '18: bad trap' message? The manual page (Ultrix 3.1) says that SIGCONT, SIGSTOP, and SIGKILL are the only untrappable signals. Dang it! I _want_ to do some massaging on a ^Z! --Blair "Gadzooks! I _asked_ one... :-/"
Re: Questions about rewriting the History function.
Author: Bill Shannon
Date: Sun, 28 Oct 1990 00:28
Date: Sun, 28 Oct 1990 00:28
113 lines
2791 bytes
2791 bytes
Several people suggested:
> You can get asynch job notification in ksh88 by doing:
>
> trap "jobs -n" CHLD
This is almost, but not quite, good enough for what I want. I want
to be able to emulate both the csh "set notify" command and the csh
"notify" command. The above emulates only the "set notify" command.
Here's a message I set to Korn on this subject some time ago:
From shannon Sat May 27 02:24:58 1989
To: dgk@ulysses.att.com
Subject: traps
I'm playing around with trapping SIGCHLD to emulate the csh notify
command. the following code in io_intr() causes a newline to be
printed every time you execute the trap handler, even if it produces
no other output.
if(sh.trapnote&TRAPSET)
{
newline();
fp = st.standin;
sh_chktrap();
io_clear(fp);
return(0);
}
for example, do
trap true CHLD
sleep 5 &
there might be cases where the newline is helpful, but in this
case it makes it impossible for me to do what I want to do.
(that coupled with the fact that functions can't effect the traps
of the mainline shell. otherwise I could set and unset the trap
when necessary and that might be good enough.)
how do you feel about removing that call to newline(), or at least
making it conditional on something so it won't happen when catching
SIGCHLD?
FYI, here's as far as I've gotten with my notify emulation. this
works pretty well, but I think there's other problems in the shell
that prevent it from working perfectly. for instance, if I do
sleep 5 & sleep 5 & notify %1 %2
sometimes it tells me about both jobs and sometimes it loses one of
the jobs. any ideas what else could be wrong?
trap _notify CHLD
NOTIFY_ALL=false
unset NOTIFY_LIST
_notify()
{
typeset i j
if $NOTIFY_ALL
then
jobs -n
else
for i in ${NOTIFY_LIST[*]}
do
j=`jobs -n %$i`
if [ "$j" ]
then
echo "$j"
unset NOTIFY_LIST[$i]
fi
done
fi
}
notify()
{
typeset i j
if (($# == 0))
then
NOTIFY_ALL=true
else
for i in "$@"
do
# turn any valid job specification into a job number
j=`jobs "$i"`
case "$j" in
\[*)
j=${j%% *}
j=${j%\]}
j=${j#\[}
NOTIFY_LIST[$j]=$j
;;
esac
done
fi
}
unnotify()
{
if (($# == 0))
then
NOTIFY_ALL=false
else
# XXX - not done yet
:
fi
}
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