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

Reply via email to