Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Fix %- (prevjob) picking wrong job after resuming



This looks pretty reasonable.  One question:

On Sun, Mar 22, 2026 at 3:08 AM Mikel Ward <mikel@xxxxxxxxxxxxx> wrote:
>
> diff --git a/Src/jobs.c b/Src/jobs.c
> index 4905ae925..e32e35bdc 100644
> --- a/Src/jobs.c
> +++ b/Src/jobs.c
> @@ -523,6 +523,11 @@ update_job(Job jn)
>                  * fg/bg is the superjob) a SIGCONT if we need it.
>                  */
>                 sjn->stat |= STAT_CHANGED | STAT_STOPPED;
> +               if ((sjn->stat & (STAT_DONE | STAT_STOPPED)) ==
> +                   STAT_STOPPED) {

Since STAT_STOPPED has just been OR'd into sjn->stat,
(sjn->stat & (STAT_DONE | STAT_STOPPED)) == STAT_STOPPED
is equivalent to
(!(sjn->stat & STAT_DONE)).  Is the latter a clearer expression of the
intent of this test?

> +                   prevjob = curjob;
> +                   curjob = i;
> +               }
>                 if (isset(NOTIFY) && (sjn->stat & STAT_LOCKED) &&
>                     !(sjn->stat & STAT_NOPRINT)) {
>                     /*




Messages sorted by: Reverse Date, Date, Thread, Author