[Top][All Lists]

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

Shell exits after process substitution when using DEBUG trap with extdeb

From: Jonathan Rascher
Subject: Shell exits after process substitution when using DEBUG trap with extdebug
Date: Mon, 3 Aug 2020 20:44:42 -0500

$ bash --version
GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)

$ uname -a
Linux penguin 5.4.40-04224-g891a6cce2d44 #1 SMP PREEMPT Tue Jun 23 20:21:29
PDT 2020 x86_64 GNU/Linux

(This is a Pixelbook running the default Crostini Linux VM under Chrome
OS 84.0.4147.110. I can reproduce the issue on regular Debian too, though.)

To reproduce, run the following commands:

shopt -s extdebug
trap : DEBUG
: < <(:)

Now, type any character (e.g., 'a'). At this point, you'll see bash print
`exit`, and the shell does indeed exit. Additionally, assuming you ran bash
inside another shell, you'll see the 'a' character is echoed.

It's a hard to describe clearly, but the result looks like this
(`bcat@penguin:pts/0` is the prompt from my outer shell):

bcat@penguin:pts/0 J:0 ~
$ bash --norc
bash-5.0$ shopt -s extdebug
bash-5.0$ trap : DEBUG
bash-5.0$ : < <(:)
bash-5.0$ [I TYPED 'a' HERE]exit
bcat@penguin:pts/0 J:0 ~
$ a

The inner shell with the DEBUG trap acts as if it received an EOF on stdin,
and exits accordingly, but the 'a' character I typed into my terminal is
indeed still there, and it's echoed by the outer shell after the inner
shell (wrongly) exits. I wonder if stdin of the inner shell is getting
screwed up by the extdebug DEBUG trap somehow.


reply via email to

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