bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Readline history and bash's read -e


From: Phil Endecott
Subject: Readline history and bash's read -e
Date: Sat, 01 Sep 2007 00:11:58 +0100

Dear Bash and Readline Experts,

I have a simple shell script that reads user commands in a loop using
"read -e".  -e enables readline, but not its history feature.  Is there
any way to get readline history with bash's read builtin?

I wouldn't want to get the user's regular bash history; rather, this
program would need its own history file in the user's home directory.
For example:

read -e --historyfile=~/.myprogname_history CMD


If there's no way to do this with the read builtin, perhaps there's an
existing standalone readline wrapper program that can do this?  I
imagine it would only need a dozen lines of code.  However, it wouldn't
be possible to retain the syntax of the read builtin w.r.t. variable names:

CMD=`read_with_history -e --historyfile=~/.myprogname_history`

If such a program doesn't yet exist, I'll write it; let me know if you
would find the code useful.  Searching has found some other wrappers
(e.g. 3 at packages.debian.org) that solve the slightly different and
more complex problem of wrapping an entire  program that doesn't use
readline so that it does use it for all input.  That's not what I need
in this case.


Thanks for any advice.

Phil.
















reply via email to

[Prev in Thread] Current Thread [Next in Thread]