On 9/7/14, 6:40 PM, micka...@gmail.com wrote:

> Bash Version: 4.3
> Patch Level: 24
> Release Status: release
> 
> Description:
>       Given the following script (test.sh) :
> 
>       #!/bin/bash
>       cleanup() { :; }
>       trap cleanup 0
>       read -e dummy
> 
>       Run the script ('bash test.sh') *in ZSH* and when it waits for an input,
>       interrupt it with Ctrl-C.

Thanks for the report.  The problem is that bash doesn't clean up readline
and its terminal state in all cases that can result in its calling
longjmp() or exiting the shell.  I've attached a patch that should fix the
problem.

The problem doesn't manifest itself in bash because bash saves the terminal
state before a command runs and restores it when the command is terminated
by a signal.

Chet


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.3-patched/bashline.c	2014-05-14 09:22:39.000000000 -0400
--- bashline.c	2014-09-08 11:28:56.000000000 -0400
***************
*** 203,206 ****
--- 203,207 ----
  extern int array_needs_making;
  extern int posixly_correct, no_symbolic_links;
+ extern int sigalrm_seen;
  extern char *current_prompt_string, *ps1_prompt;
  extern STRING_INT_ALIST word_token_alist[];
***************
*** 4209,4214 ****
    /* If we're going to longjmp to top_level, make sure we clean up readline.
       check_signals will call QUIT, which will eventually longjmp to top_level,
!      calling run_interrupt_trap along the way. */
!   if (interrupt_state)
      rl_cleanup_after_signal ();
    bashline_reset_event_hook ();
--- 4262,4268 ----
    /* If we're going to longjmp to top_level, make sure we clean up readline.
       check_signals will call QUIT, which will eventually longjmp to top_level,
!      calling run_interrupt_trap along the way.  The check for sigalrm_seen is
!      to clean up the read builtin's state. */
!   if (terminating_signal || interrupt_state || sigalrm_seen)
      rl_cleanup_after_signal ();
    bashline_reset_event_hook ();
*** ../bash-4.3-patched/sig.c	2014-01-10 15:06:06.000000000 -0500
--- sig.c	2014-09-08 11:26:33.000000000 -0400
***************
*** 533,538 ****
    /* Set the event hook so readline will call it after the signal handlers
       finish executing, so if this interrupted character input we can get
!      quick response. */
!   if (interactive_shell && interactive && no_line_editing == 0)
      bashline_set_event_hook ();
  #endif
--- 533,540 ----
    /* Set the event hook so readline will call it after the signal handlers
       finish executing, so if this interrupted character input we can get
!      quick response.  If readline is active or has modified the terminal we
!      need to set this no matter what the signal is, though the check for
!      RL_STATE_TERMPREPPED is possibly redundant. */
!   if (RL_ISSTATE (RL_STATE_SIGHANDLER) || RL_ISSTATE (RL_STATE_TERMPREPPED))
      bashline_set_event_hook ();
  #endif

Reply via email to