[Ilugc] History Command

  • From: girish1729@xxxxxxxxx (Girish Venkatachalam)
  • Date: Thu Aug 17 16:46:06 2006



--- Binand Sethumadhavan <binand@xxxxxxxxx> wrote:

On 17/08/06, Girish Venkatachalam
<girish1729@xxxxxxxxx> wrote:
it. A few lines of simple C code can do it. No
need
for any "fancy" IPC. Different bash instances
could
maintain a shared mem area or some such thing.

You have just -defined- IPC - mechanisms for
different processes to
communicate to each other via memory-based
techniques ("Inter-Process
Communication"). Getting it just correct for a given
piece of software
is not an easy task.
Well, easy or difficult is purely relative dependent
on one's energy levels and genius. 

Genius is an ability to take infinite pains and with
adequate pains just about anything can be
accomplished. 

In this case however it is not relevant. It is really
simple to do.

First of all let me clarify that we were barking up
the wrong tree. If as per your explanation, the
history is written to disk and read from disk, then
obviously it wouldn't work if you press the up arrow
once you in a shell. I know you didn't mean to say
that.

In any case I am sure this is an area of improvement
for bash and if coded properly GNU should accept the
patch. Too bad I don't have the bandwidth to do it
right now.

Anyway here is the logic for anyone with the necessary
courage and determination. A patch on your resume
wouldn't look too bad, would it? :-)

I have no idea about bash internals but one can guess
reasonably well. 

I think as of now , bash merely stores the command
history in a buffer for each bash process, one for
each pty. Now, all I am saying is that as and when the
user types a certain command in a certain bash
instance, one has to maintain a queue of commands and
each command should get appended to it. One could use
any mechanism to achieve that. 

One simple way would be to have a UNIX domain socket
listen for command lines. Or you could append it to a
file also. After all files are also a very simple and
effective IPC mechanism.

Now, the in core history buffer has to be updated
either from the file or from the socket depending upon
the way you decide to implement it. 

The socket approach has a problem that it has to flush
the queue to a file every now and then. We could use a
setitimer() for that. No need for threads...

Any takers for the patch? :-)

This makes a good student project for those of you
interested in doing something that is going to be used
by others.

However I certainly cannot guarantee that GNU folks
will apply the patch. You never can guess human
psychology.

FWIW this will certainly give you good exposure to
UNIX and to a certain degree programming too...

regards,
Girish


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com ;

Other related posts: