Search code examples
bashshellcygwinreadline

Rlwrap doesn't seem to cooperate with "read -e"


A new twist to somewhat common question:

In my interactive script I pre-fill the user input like so:

#process_line.sh

INPUT=$1 # previous value
read -e -p "> " -i "$INPUT" INPUT

To implement command history I call process_line.sh

    rlwrap ./process_line.sh $INPUT

Now here's the twist: if I have the "read -e" option, I can edit the pre-filled input BUT there is no command history, and adversely, I can have command history, courtesy of rlwrap , without the "read -e" option, but no pre-filling (that is, "read -i" doesn't really do anything).

The question, of course, is whether I can have both input pre-fill and editing AND command history at the same time.

Thanks!


Solution

  • Turn off the -e to read. Then the two readline implementations won't clash.

    To get the prompt, you can pass -S "> " to rlwrap.