bug-bash
[Top][All Lists]
Advanced

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

Re: set -e doesn't trigger when command substitutions returns, why?


From: microsuxx
Subject: Re: set -e doesn't trigger when command substitutions returns, why?
Date: Thu, 19 Jun 2025 09:25:37 +0200

hello there ..
to return $( and maybe <( use wait -n

bash -e -c $'trap \'wait -n ; (( $? )) && exit 1\' debug ; echo $(exit 1) ;
echo survived'
$ u0_a427/10427 localhost 09:24:18 19.06.2025
~


<no survived>

On Thu, Jun 19, 2025, 12:39 AM Никола Константинов Кралев <
nkkralev@uni-sofia.bg> wrote:

> ```
> u can try
>
> trap '(( $? )) && exit 2' debug
>
> ```
> I mean, I know that $? doesn't detect the tests I posted in my first
> email, even if we do
>
> bash -e -c 'echo $(exit 1) ; echo survived'
>
> We see that survived is printed, this trap snippet you wrote here seems to
> duplicate what set -e does? I repeated the tests I had, and the trap
> doesn't make a difference. My favorite way to track step by step execution
> is set -x and editing $PS4 of course, but those are just read only debug
> tools and they can't force bash to exit early.
>
> So, from all the replies I see here, I learned that this is not a bug,
> unfortunately, and is just how set -e works, and trying to do bulletproof
> status code checking with it is just, not perfect enough, and never will be.
> Thank you all, the bug report can be marked as resolved not-a-bug.
>


reply via email to

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