Re: how to get out of the vi editing mode

2009-06-24 Thread Chet Ramey
> I hit something by accident and command line editing no longer works.
> (I think I switched to the vi mode).
> 1. how do I get back to the emacs mode? (aka what did I hit?!)

If you're really in vi mode, use set -o emacs.  If you're just in some
sub-mode, try ^G.

> 2. how do I disable vi mode forever and ever (short of recompiling bash 
> myself)?

You can't, really, without rebuilding.  (And I haven't tried building without
vi mode in a long time.)

The reason I asked whether or not you really were in vi mode is that bash
unbinds all of the key bindings that will take you from emacs mode to vi
mode and vice versa.  For instance, I get the following output when in
emacs mode:

$ bind -p | grep mode
# emacs-editing-mode (not bound)
# overwrite-mode (not bound)
# vi-append-mode (not bound)
# vi-editing-mode (not bound)
# vi-insertion-mode (not bound)
# vi-movement-mode (not bound)

and similar output when in vi mode.

Chet




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

Chet Ramey, ITS, CWRUc...@case.eduhttp://tiswww.tis.case.edu/~chet/




Re: feature request: more complete set -e

2009-06-24 Thread Marc Weber
On Tue, Jun 23, 2009 at 09:00:10AM -0400, Chet Ramey wrote:
> Marc Weber wrote:
> > Hi,
> > 
> > I stumbled about another bash problem today:
> > 
> > for item in $(false);
> >   echo $item
> > done || { echo for failed; }
> > 
> > doesn't fail. I think it's bad that there is no
> >   set -e 
> > 
> > like switch which really catches all failures of this kind.
> 
> This isn't really about set -e or ||; the for loop doesn't fail.
> 
> Posix.2 says, in part,
> 
>   "[T]he list of words following in shall be expanded to generate
>a list of items...If there are no items, the exit status shall
>be zero."
> 
> http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04_03

This is my point: I'd like to tell bash: Whenever running an executable
assume that if it returns a non zero exit status that's a unforeseen
exception. And in this case don't continue as usual but abort and return
non zero exit status yourself. set -e comes close.

Maybe this is not posix compliant. But I think it would be useful to
have this kind of propagating error conditions in all cases.

Of course for i in $(echo ""); .. ; done should still result in exit
status 0. But if echo was an executable failing due to any reason (eg
segmentation fault) there should be a way to make the script fail
without having to remember that a dummy var has to be used like this:
dummy=$(fail)
for i in $dummy; do .. ; done

I'm only one user in the world and I can't say what all bash users want.
I'd like to see this feature making my script yell if there is an
exception.

I don't want to offend bash. I want to see it turning into a fool
proof direction because bash is not the only language I have to use
which makes it harder to remember all details.

Sincerly
Marc Weber