On Thursday 28 June 2007 15:34, Seb wrote:
> Hello,
> 
> It seems that there is a bug in the 'jobs' built-in command of ash. As
> a matter of fact, its output cannot be captured nor piped.
> 
> I made a little script (in attachment) which shows the case. If you
> execute it with ash, you should see that 'test3' doesn't return
> anything but a new line, while 'test4' indicates that the output is well
> directed to stdout (so, according to the rules of shell, the pipe
> should work).
> 
> I first observed this bug with the ash shell embedded in Slackware
> (then I tested the one of Busybox because Patrick Volkerding said
> to me that it was probably the best maintained ash shell :-) and I saw
> that dash has the same curious behaviour. So, I think this bug comes
> from the "historical" ash shell. The 'TOUR' doc which is in the ash
> shell Slackware package says that ash cooks its own outputs, hence here
> could be the cause of the bug (complete file in attachment):

The bug is simple: ash clears job list for children. "jobs | cat" is run
in child, because it's a pipe.

I think the following will fix it: at the end of forkchild() function
replace for() loop with this #if block:

#if JOBS
        /* For "jobs | cat" to work like in bash, we must retain list of jobs,
         * but need to remove ourself */
        freejob(jp);
#else
        for (jp = curjob; jp; jp = jp->prev_job)
                freejob(jp);
#endif
        jobless = 0;
}

I'm curious, tho, whether this will break other job-related stuff.

Can you test this change?
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to