[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What exactly does "read -e" do? bind weirdnesses
From: |
rocky |
Subject: |
What exactly does "read -e" do? bind weirdnesses |
Date: |
Wed, 10 Sep 2008 19:04:17 -0700 (PDT) |
User-agent: |
G2/1.0 |
The most recent bash docs say this about builtin function read with
option -e:
Readline (@pxref{Command Line Editing}) is used to obtain the line.
Consider this little program:
PS4='-$LINENO: $? $ '
set -x
builtin bind '"\C-x\C-r": "bind completion"'
builtin bind -P
while read -e -p 'huh? ' line ; do
echo $line
done
when I run it and enter C-x-C-r (control x + control -r) when it
prompts for input here is what I see.
$ bind '"\C-x\C-r": "bind completion"'
$ bash ./rlbug.sh
-3: 0 $ builtin bind '"\C-x\C-r": "bind completion"'
-4: 1 $ builtin bind -P
-5: 1 $ read -e -p 'huh? ' line
huh?
-6: 0 $ declare -p line
declare -- line=""
-5: 0 $ read -e -p 'huh? ' line
There are a number of things going on, none of which can I find
answered in bashref.texi for bashd 4.0 alpha or 3.2.
First, I gather from the return code 1 that bind is failing inside the
script. All right, but no error message or warning is given? In an
interactive shell if I enter say "bind -Z" at least I will get a
message saying that the bind option is invalid. Inside a script though
nothing.
Second although -e allows for some sorts of readline editing there are
other kinds of readline expansions that aren't getting run, In
particular C-x-C-r. Last and probably related, is the fact that C-x-C-
r isn't stored in variable line. (Adding -r to "read" doesn't change
things.)
Ideally, it would be nice to have read routine that made use of the
full features of readline. Failing that, it would be nice to have
documented what features one gets with "read -e" and what features one
doesn't get.
Thanks
- What exactly does "read -e" do? bind weirdnesses,
rocky <=
- Re: What exactly does "read -e" do? bind weirdnesses, Chet Ramey, 2008/09/11
- Re: What exactly does "read -e" do? bind weirdnesses, Rocky Bernstein, 2008/09/11
- Re: What exactly does "read -e" do? bind weirdnesses, Chet Ramey, 2008/09/11
- Re: What exactly does "read -e" do? bind weirdnesses, Rocky Bernstein, 2008/09/11
- Re: What exactly does "read -e" do? bind weirdnesses, Chet Ramey, 2008/09/11
- Re: What exactly does "read -e" do? bind weirdnesses, Rocky Bernstein, 2008/09/11
- Re: What exactly does "read -e" do? bind weirdnesses, Chet Ramey, 2008/09/13
- Re: What exactly does "read -e" do? bind weirdnesses, Rocky Bernstein, 2008/09/17
- Re: What exactly does "read -e" do? bind weirdnesses, Chet Ramey, 2008/09/23
- Re: What exactly does "read -e" do? bind weirdnesses, Rocky Bernstein, 2008/09/23