|
From: | Robert E. Griffith |
Subject: | Re: Bug that only happens in ubuntu 22.04 even with older bash version |
Date: | Sat, 20 Aug 2022 11:49:13 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 |
On 8/10/22 09:26, Chet Ramey wrote:
On 8/8/22 12:11 PM, Robert E. Griffith wrote:Does anyone know how bash 5.0 and 5.1 on ubuntu 22.04(jammy) could behave differently from bash 5.0 and 5.1 onĀ 20.04(focal)?It's probably something in an ubuntu startup file somewhere. Who knows? But I get the same results you do using bash-5.1. Here's why.
The difference in the two Ubuntu versions is explained now. I was testing like "bash5.x -c <scriptname>" but since my test scripts all have shebang lines, it was always running it in the native installed bash version so I was not actually testing in other bash versions. Sorry for the confusion.
Once I understood the full impact of the 5.1 recursive DEBUG trap change, I resolved most of my issues but I have one more that seems like a bug introduced in 5.1. When stepping through a non-DEBUG trap with the DEBUG trap, BASH_COMMAND does not update until the trap is finished.
#!/usr/bin/env bash echo $BASH_VERSION shopt -s extdebug function setExitCode() { return $1; } function aNoopCommand() { echo "aNoopCommand 1"; } trap 'echo USR1: start; aNoopCommand' USR1 trap 'echo "DBG: $BASH_COMMAND" [[ "$BASH_COMMAND" =~ ^aNoopCommand ]] && echo "!!! Hit it" setExitCode 0 ' DEBUG kill -USR1 $BASHPID echo 1 [bobg@bgcore-centosS9]$ bin/test51_2.sh 5.1.8(1)-release DBG: kill -USR1 $BASHPID DBG: kill -USR1 $BASHPID USR1: start DBG: kill -USR1 $BASHPID DBG: kill -USR1 $BASHPID DBG: kill -USR1 $BASHPID aNoopCommand 1 DBG: echo 1 1 bobg@ubuntu-focal:$ bin/test51_2.sh 5.0.17(1)-release DBG: kill -USR1 $BASHPID DBG: kill -USR1 $BASHPID USR1: start DBG: aNoopCommand !!! Hit it DBG: aNoopCommand !!! Hit it DBG: echo "aNoopCommand 1" aNoopCommand 1 DBG: echo 1 1I believe that this script does not make any subshells so its different from the other behavior.
In the bash 5.0 run (the second run listed) the BASH_COMMAND is not updated for the first simple command in the USR1 trap string but it does get updated for the second (and subsequent) simple command and it correctly triggers the "!!! Hit it" statement.
In the bash 5.1 run, BASH_COMMAND never updates while the USR1 trap string is running and it misses the "!!! Hit it" line.
In 5.1 I can still step through a USR1 trap in my debugger but its very confusing because BASH_COMMAND never updates so the debugger code cant know which part of the current line is running. In 5.0, the first step is messed up but then it corrects itself in the next step.
Is that a deliberate change in 5.1 or is that a bug. (Keeping my fingers crossed its a bug:)
--BobG
[Prev in Thread] | Current Thread | [Next in Thread] |