mainThe GNU Bourne-Again SHell - Support: sr #110335, Interrupt in command substitution...

 
 

sr #110335: Interrupt in command substitution exits interactive bash

Submitter:  Robert Hensing <roberth>
Submitted:  Tue 20 Oct 2020 11:31:38 AM UTC
Votes: 50
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Done
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 21 Dec 2020 02:31:51 PM UTC, comment #7: 

This is fixed in bash-5.1.

Chet Ramey <chet>
Group administrator
Sun 20 Dec 2020 11:30:08 PM UTC, comment #6: 

I can reproduce reliably this way.

In the following environment:


$ echo $PROMPT_COMMAND
_direnv_hook
$ type _direnv_hook
_direnv_hook is a function
_direnv_hook ()
{
    local previous_exit_status=$?;
    trap -- '' SIGINT;
    eval "$("/nix/store/21f554786n26jy6nq2z9xp8687zi0ach-direnv-2.25.0/bin/direnv" export bash)";
    trap - SIGINT;
    return $previous_exit_status
}
$ ls -a
.  ..  .direnv  .envrc  shell.nix
$ cat .envrc
use nix
$ cat shell.nix
(import <nixpkgs> { }).mkShell {
  name = "test";
}
$ bash --version
GNU bash, version 4.4.23(1)-release (x86_64-apple-darwin17.7.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ which bash
/nix/store/x5l2ffyi01f109rk44cihgv71af1jz7z-bash-interactive-4.4-p23/bin/bash
$


I hold down Ctrl-C to spam SIGINT to bash. It will exit after a few seconds of this. I'm not sure what aspect of my environment is causing this, but setting PROMPT_COMMAND='' seems to make it stop happening.

Luke Worth <lrworth>
Mon 26 Oct 2020 01:05:25 PM UTC, comment #5: 
Chet Ramey <chet>
Group administrator
Wed 21 Oct 2020 04:46:25 PM UTC, comment #4: 

This behavior seems to be triggered by direnv, but it can not be fixed by direnv. See https://github.com/direnv/direnv/issues/627 for discussion and yet another way to trigger the problem.

Robert Hensing <roberth>
Tue 20 Oct 2020 02:47:14 PM UTC, comment #3: 

I tested on macOS and Fedora 31, and I did ^C it.

Chet Ramey <chet>
Group administrator
Tue 20 Oct 2020 02:01:32 PM UTC, comment #2: 

It happens for me with bash 5.0-p18 on NixOS, which has no extra patches besides enabling PGRP_PIPE.

Just in case, you did send a Ctrl+C, right? I didn't state clearly that you have to ^C it yourself.

Robert Hensing <roberth>
Tue 20 Oct 2020 12:17:42 PM UTC, comment #1: 

I can't reproduce this using similar conditions as #108593 with
bash-5.0 or bash-5.1-rc1.

Chet Ramey <chet>
Group administrator
Tue 20 Oct 2020 11:31:38 AM UTC, original submission:  

To reproduce


bash$ echo $(sleep 10)
^C


This exits the bash process, typically causing terminal emulator windows to close. I've tested this in Konsole, xfce4-terminal, xterm and gnome-terminal.

Interrupting sleep 10 by itself works just fine.
Variations with command substitution in a different 'role' produce the same outcome. For example $(sleep 10) by itself or a=$(sleep 10).

This is similar to but distinct from https://savannah.gnu.org/support/?108593 which is about process substitution and has been resolved.

Robert Hensing <roberth>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lrworth (Posted a comment)
  • -email is unavailable- added by lrworth (Voted in favor of this item)
  • -email is unavailable- added by arne
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by roberth (Submitted the item)
  •  

    There are 50 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-12-21 chet StatusWorks For Me Done
    2020-12-20 lrworth Carbon-Copy- Added lrworth
    2020-10-22 arne Carbon-Copy- Added -email is unavailable-
    2020-10-20 chet StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code