Thanks for the answer,
It could be an intentional change, but compared with the previous version or bash the behavior is quite different, and it can cause issues with several scripts.
Also, I didn’t find the change in behavior listed in the changelog for 5.9, so it may be a new bug or regression.
I just use that line to define my PROMPT
and I can easily update, but I worry that the change could be more troublesome for other packages or automation scripts.
2022-06-20 15:32:32 -0300, Paulo Diovani:
[...]
> In version 5.9 the [[ ]] operator is behaving unexpectedly for the
> following case:
>
> $ watch ls &
> $ [ $(jobs -l | wc -l) -gt 0 ] && echo jobs found || echo no jobs
> jobs found
> $ [[ $(jobs -l | wc -l) -gt 0 ]] && echo jobs found || echo no jobs
> no jobs
[...]
While I agree that looks like a bug (the output of jobs seems to
be empty when the command substitution is expanded inside
[[...]] or ((...)) or a[$(jobs)]=... at least in my tests), a
better approach here would be to use:
if (( $#jobstates > 0 )); then
echo jobs found
else
echo no jobs
fi
--
Stephane