[Top][All Lists]

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

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

From: Rocky Bernstein
Subject: Re: What exactly does "read -e" do? bind weirdnesses
Date: Wed, 17 Sep 2008 11:24:18 -0400

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:

#!/usr/bin/env bash
set +o emacs
while read -e -p 'huh? ' line ; do
  echo $line

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?

As for duplication of text, I think there's not much worry of that in
bashref.texi. Where more effort would be appreciated is in making the
information more usable and more easily understandable. If it means
summarizing information elsewhere or adding examples at the expense of
greater verbosity and some duplication, I think this is justified.

Right now, I always edit bashref.texi in emacs because I've rarely been able
find it in the info or other processed formats. That's also why the history
mechanism in bashdb had not made better use of readline - I tried couldn't
figure out how to get it to work the way it needs to and thus left it,
instead saving my commands in my own array. It's possible others have
experienced this. Some of this may be a result of the compressed
information, although I think there are other issues such as lack of
examples or overall organization as well.

On Sat, Sep 13, 2008 at 6:29 PM, Chet Ramey <address@hidden> wrote:

> Rocky Bernstein wrote:
>> There is a connection between the "set -o emacs",  "set -o vi", and "set
>> -o
>> history" commands and the way "read -e" works. But there is nothing that I
>> could find in any of the bash/readline/history documents that make this
>> connection explicit. Changing one of these "line editing" settings changes
>> key bindings that are used in "read -e".  But this is not mentioned when
>> describing either "set" or "read". Of course, if one thinks about line
>> editing and considers where that might be used, then "read -e" is
>> tempting.
> Actually, `set -o history' is independent of command line editing; you can
> have a history list without any editing at all.  It has no effect on key
> bindings.
> The rest is a question of how many places you want to put the same
> information.  The text describing the -e option to read references
> the readline or command line editing sections of the man page and
> info file, respectively.  Those sections note that the default editing
> mode is emacs (``By default, the line editing commands are similar to
> those of emacs.''), how to change the editing mode from emacs to vi,
> how to enable and disable line editing, and that the default values of
> the `editing-mode' and `keymap' variables are `emacs', with appropriate
> descriptions of their meaning.
> The text accompanying `set -o emacs' notes that it is enabled by default
> when the shell initializes line editing.
>  Furthermore, when one puts "read -e" in a file without any line editing
>> settings, there is by default some sort of key bindings that are in
>> effect.
>> They look like some of emacs settings, perhaps all of them. But, again, I
>> don't think one can figure this out by reading available documents and I
>> don't see it obvious why that this should be the default, yet  "bind"
>> should
>> not show this.
> As noted above, the documentation makes it clear in a number of places
> that the default editing mode and key bindings are emacs-like.
> I can put something with the text describing `read -e' that it uses the
> current or default, if editing is not active, editing settings, but I'd
> really like to keep the amount of duplicated information down.
>  By the way, is "line editing" also an implied by virtue of a combination
>> of
>> settings or is there some variable, or status display that makes this
>> explicit?
> It's pretty simple.  If `set -o emacs' is on, there is emacs-like line
> editing; if `set -o vi' is on, there is vi-like editing (implmented as
> Posix specifies); if neither are on, there is no editing.
> Chet
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> Chet Ramey, ITS, CWRU    address@hidden
> http://cnswww.cns.cwru.edu/~chet/ <http://cnswww.cns.cwru.edu/%7Echet/>

reply via email to

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