bug-bash
[Top][All Lists]
Advanced

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

Re: bind -x keyseq:shell_func related misbehaviour


From: Chet Ramey
Subject: Re: bind -x keyseq:shell_func related misbehaviour
Date: Tue, 9 Apr 2002 12:33:04 -0400

> unknown Machine Type: i586-pc-linux-gnu
> 
> Bash Version: 2.05a
> Patch Level: 0
> Release Status: release
> 
> Description:
>         Using bind -x keyseq:func I assign a shell function to a key.
>         Whenever I press this key, the function is properly executed but
>         bash seems to be in an inconsistent state for the duration of the
>       next prompt.
>         NOTE: This bug was even worse in bash-2.05. It has been fixed
>       somewhat in bash-2.05a but there are still some quirks (see
>       Repeat-By).
> 
> Repeat-By:
>         # 1st problem:
>         PROMPT_COMMAND='PS1="`pwd`> "'
>         func() { cd.. ; }
>         bind -x '"\C-o":func'
>         
>         #Now press Ctrl-O. Bash gives a new prompt that shows the
>       #directory unchanged. 
>       #Press ENTER or Ctrl-C so that bash gives you a new prompt.
>         #The new prompt shows that in fact the directory was changed.

This is not a problem, just the result of some incorrect assumptions. 
PROMPT_COMMAND is executed before bash calls readline() with $PS1 as
the argument.  The `bind -x' causes `func' to be executed within the
context of that same call to readline().  Since readline() is only
called once, the prompt does not change. 

>         # 2nd problem:
>         alias l='ls -la'
>         func() { : ; }  
>         bind -x '"\C-o":func'
>         l  #just to see that the alias works
>         drwxr-xr-x    2 root     root         4096 Jan 28 15:26 .
>         drwxr-xr-x   21 root     root         4096 Feb 16 11:38 ..
>         
>         #Now press Ctrl-O. Bash gives a new prompt.
> 
>         l   #try the alias again 
>         bash: l: command not found
>         #^^^^^^^^^^^^^^^^^^^^^^^^^  Somehow bash has forgotten the alias

Thanks, I'll take a look.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    chet@po.CWRU.Edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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