bug-bash
[Top][All Lists]
Advanced

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

Re: What exactly does "read -e" do? bind weirdnesses


From: Chet Ramey
Subject: Re: What exactly does "read -e" do? bind weirdnesses
Date: Tue, 23 Sep 2008 08:46:12 -0400
User-agent: Thunderbird 2.0.0.16 (Macintosh/20080707)

Rocky Bernstein wrote:
> Sorry for the delayed reply.
> 
> As I now understand it, the situation right now seems a bit
> inconsistent. "read -e" in a script uses emacs bindings by default even
> if I've entered "set -o emacs" which I note in the following example:

(I'm assuming you mean `set +o emacs'.)

> #!/usr/bin/env bash
> set +o emacs
> while read -e -p 'huh? ' line ; do
>   echo $line
> done
> 
> 
> But the behavior of "bind -p" is to show nothing, and possibly in the
> future to give an error saying that "line editing" is not on. And this
> seems inconsistent. In the context of a script, if "bind -p" isn't
> reporting on what happens in "read -e", then what is it reporting on? 
> And if it is reporting about what happens in "read -e" then should it
> not also "default" to emacs bindings when asked to print what is in effect?

It's not that complicated. :-)

You turned off line editing with `set +o emacs'.  At this point, bind will
report an error because editing is not enabled (debatable behavior, but
it is what it is).  You then invoke `read -e', explicitly asking for
readline and line editing, and read a line of text.

What would you have it do?  Line editing is off, disabled with set +o, but
read has been told to use readline to obtain the user's input.  Since
editing is disabled, readline uses its default behavior: emacs-like key
bindings.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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