[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Probably a bug in ash
From:       Seb <sbb () tuxfamily ! org>
Date:       2007-06-28 14:34:39
Message-ID: 20070628163439.50345aac.sbb () tuxfamily ! org
[Download RAW message or body]

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):

"OUTPUT:  Ash uses it's own output routines.  There are three out-
put structures allocated.  "Output" represents the standard out-
put, "errout" the standard error, and "memout" contains output
which is to be stored in memory.  This last is used when a buil-
tin command appears in backquotes, to allow its output to be col-
lected without doing any I/O through the UNIX operating system.
The variables out1 and out2 normally point to output and errout,
respectively, but they are set to point to memout when appropri-
ate inside backquotes."

I'm not skilled at all in C, so I can help much more. And I don't know
if it's possible to make a "portable" patch for other ash shells,
despite it would be great for everyone.

Hopefully this can however be useful for busybox,

++
Seb.


P-S. I don't know if it matters, but I tested the issue on a busybox
compiled with the default configuration.

["ashjbtest.sh" (application/octet-stream)]

#!/bin/sh
sleep 3s &
echo "test 1: 'jobs' alone."
jobs
echo "test 2: 'jobs' with a pipe to xargs."
jobs | xargs
echo "test 3: 'jobs with stdout redirected to /dev/null."
jobs >/dev/null
echo "waiting for the end of jobs..."
wait
# EOF 

["TOUR.gz" (application/octet-stream)]

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic