Re: "jobs" builtin: print zero exit status

2013-09-14 Thread Dmitry Bolshakov
"wait" blocks, "jobs" - does not

-- 
with best regards
Dmitry Bolshakov

12.09.2013, 22:34, "Chet Ramey" :
> On 9/12/13 6:14 AM, Dmitry Bolshakov wrote:
>
>> Hi!
>> imho "jobs" should either print zero exit status or it should be
>> documented that "Done" means zero exit status
>> $ bash -c 'set -m; perl -e "sleep 1; exit 123"& { sleep 3; jobs -l; }'
>> [1]+е║ Exit 123е║е║е║е║е║е║е║е║е║е║е║е║е║е║е║ perl -e "sleep 1; exit 123"
>> ok, I see exit status
>> but
>> $ bash -c 'set -m; perl -e "sleep 1; exit 0"& { sleep 3; jobs -l; }'
>> [1]+е║ Doneе║е║е║е║е║е║е║е║е║е║е║е║е║е║е║е║е║е║е║ perl -e "sleep 1; exit 
>> 0"
>> imho "Exit 0" would be better for scripting
>
> The format of the text isn't in the man page at all.  Parsing the output
> of jobs is a really terrible way to figure out a job's exit status.  You
> might try using `wait'.
>
> Chet
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/




Re: "jobs" builtin: print zero exit status

2013-09-14 Thread Pierre Gaston
On Sat, Sep 14, 2013 at 3:14 PM, Dmitry Bolshakov  wrote:
> "wait" blocks, "jobs" - does not
>

>
you can use "if kill -0 $pid;then ..."  to see if it's still running,
then wait to get the pid