bug-bash
[Top][All Lists]
Advanced

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

Re: wait -n -p var assigns a random number to var if there are no jobs


From: Oğuz
Subject: Re: wait -n -p var assigns a random number to var if there are no jobs
Date: Fri, 11 Dec 2020 14:06:57 +0300

Seems to be a minor mistake, even I could manage to fix it :D

diff --git a/builtins/wait.def b/builtins/wait.def
index 12260737..e25f7b5b 100644
--- a/builtins/wait.def
+++ b/builtins/wait.def
@@ -213,11 +213,11 @@ wait_builtin (list)
        }

       status = wait_for_any_job (wflags, &pstat);
+      if (vname && status >= 0)
+       bind_var_to_int (vname, pstat.pid);
       if (status < 0)
        status = 127;

-      if (vname && status >= 0)
-       bind_var_to_int (vname, pstat.pid);
       if (list)
        unset_waitlist ();
       WAIT_RETURN (status);

Oğuz


On Fri, Dec 11, 2020 at 1:25 PM Oğuz <oguzismailuysal@gmail.com> wrote:

> See:
>
> $ echo $BASH_VERSION
> 5.1.0(1)-release
> $
> $ jobs
> $ wait -n -p var
> $ echo $var $?
> 66390280 127
>
> If it left `var' unset that would be way more helpful to determine whether
> one of the jobs exited with 127 or all the jobs were waited for and none
> left.
>
> Oğuz
>


reply via email to

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