Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"read -e" (Spinoff of other thread about line editing in shell script)

15 views
Skip to first unread message

Kenny McCormack

unread,
Jan 13, 2024, 1:11:28 PMJan 13
to
Re: Discussion in other thread about whether or not "read -e" works (for
suitable values of "works").

I have to admit that I just tested it on the command line and it worked as
expected (up/down arrows scrolled back and forth over my previously entered
shell command lines). So, I expected/assumed it would work in a script.
But, alas, it doesn't.

Here's my test script:

--- Cut Here ---
#!/bin/bash
### INPUTRC=/tmp/inputrc
### HISTFILE=/tmp/histfile
set -o vi
while read -ep "Enter something: "
do echo "You said: $REPLY"
done
--- Cut Here ---

The INPUTRC file contains "set history-size 100".

The funny thing is that the arrow keys are recognized, and the left/right
works as expected, but up/down doesn't retrieve previous lines.

Anyway, it will be interesting to see if anyone else can get this to work.
Note: I am *not* looking for "tech support" on the above script. I am trying
to see if anyone else can get it to work for themselves, or if Christian is
indeed right that it simply doesn't work.

BTW, what I mean by "the keys are recognized" is that they don't echo on
the screen as something like [A or whatever, as they would if we omit the
"-e" from the "read" statement.

--
Debating creationists on the topic of evolution is rather like trying to
play chess with a pigeon --- it knocks the pieces over, craps on the
board, and flies back to its flock to claim victory.
0 new messages