EXIT trap is not executed after an exec failure in a non-interactive shell

2021-09-30 Thread Mark March
If execfail is set, a failed exec does not cause a non-interactive shell to exit, but it seems to reset the EXIT trap: cat <<'EOF' | bash shopt -s execfail trap "echo exiting..." EXIT exec ~/does-not-exist echo "exec failed in bash-$BASH_VERSION" exit 1 EOF Output: bash: line 3: /home/march/doe

Re: EXIT trap is not executed after an exec failure in a non-interactive shell

2021-09-30 Thread Mark March
:13 PM PDT, Alex fxmbsw7 Ratchev wrote: i think its not a bug but normal runtime as ive understood, exec 'replaces' itself with , then no more continued code well error checking could maybe be better On Fri, Oct 1, 2021, 01:25 Mark March wrote: > If execfail is set, a fail

Re: EXIT trap is not executed after an exec failure in a non-interactive shell

2021-10-01 Thread Mark March
ey wrote: On 9/30/21 7:24 PM, Mark March wrote: > If execfail is set, a failed exec does not cause a non-interactive shell to > exit, but it seems to reset the EXIT trap: Yes. When the shell runs `exec', it assumes the execed program will overlay the shell process. To make that hap

Re: EXIT trap is not executed after an exec failure in a non-interactive shell

2021-10-08 Thread Mark March
her hand, not doing this will lead to subtle bugs where cleanup code will suddenly not run, or processes unexpectedly catch signals that have been previously blocked. -Mark On Friday, October 8, 2021, 08:02:31 AM PDT, Chet Ramey wrote: On 10/1/21 2:16 PM, Mark March wrote: > Ok, thank yo

${y@a} on an empty array y fails with 'y: unbound variable' if run with set -u

2021-10-25 Thread Mark March
If -u is on and you declare a simple or associative array 'y' and set it empty, then ${y@a} will fail with 'unbound variable'. I was able to repro this under 5.1.0(1)-release and 5.1.8. 5.0.17(1)-release does not seem to be affected. The code to reproduce (output lines begin with #>): echo $BAS

Re: ${y@a} on an empty array y fails with 'y: unbound variable' if run with set -u

2021-10-26 Thread Mark March
amp;& { set +u; ... set -u; } around my [[ ${foo@a} =~ A ]] for now. Thanks again for your explanation and context. -Mark On Tuesday, October 26, 2021, 07:02:59 AM PDT, Chet Ramey wrote: On 10/25/21 8:24 PM, Mark March wrote: > If -u is on and you declare a simple or associative array

read -t0 may report that input is available where none is possible

2021-11-20 Thread Mark March
true | { sleep 1 ; read -rt0 ; echo $?; } outputs 0. There can clearly be no data on the stdin of the second process in the pipeline. bash(1) has this to say about read -t: "If timeout is 0, read  returns  immediately, without trying to read any data. The exit status is 0 if input is availabl

a nameref may resolve to different variables in assignment and parameter expansion

2022-01-06 Thread Mark March
It appears that the same initialized nameref variable may refer to variables in different scopes depending on the context where it is used. When used in an assignment, a nameref will look for the variable it references starting at the scope where the nameref itself was found, which may be below

DEBUG trap in a background shell steals controlling terminal forcing parent shell to exit

2024-06-18 Thread Mark March
I am working with a large Bash code base where most scripts disable job control and the DEBUG trap is used extensively. I noticed that if I tried to run my scripts in the background, the interactive shell that started them would immediately exit on any keyboard input. A simple repro is to run b

Re: DEBUG trap in a background shell steals controlling terminal forcing parent shell to exit

2024-06-25 Thread Mark March
e any work-arounds other than not using the DEBUG trap or leaving job control on? -Mark On Tuesday, June 18, 2024 at 02:48:51 PM PDT, Mark March wrote: I am working with a large Bash code base where most scripts disable job control and the DEBUG trap is used extensively. I noticed th

Re: DEBUG trap in a background shell steals controlling terminal forcing parent shell to exit

2024-07-01 Thread Mark March
Thank you for a quick fix. Bash 5.2.21 with the patch applied no longer exhibits the problem in my tests. -Mark On Thursday, June 27, 2024 at 06:05:28 AM PDT, Chet Ramey wrote: On 6/18/24 4:55 PM, Mark March wrote: > I am working with a large Bash code base where most scripts disa

Re: waiting for process substitutions

2024-07-02 Thread Mark March via Bug reports for the GNU Bourne Again SHell
lastpipe takes effect only if job control is off. From the man page:     lastpipe   If set, and job control is not active,  the  shell With laspipe on and job control off, 'wait' appears to wait for all process substitutions: set +mshopt -s lastpipe echo $'foo\nbar' | tee