On Tue, Jul 21, 2009 at 7:17 PM, Frans Pop<elendil@xxxxxxxxx> wrote: > On Tuesday 21 July 2009, Steve Calfee wrote: > I enabled all the debug print statements in your script; what I get is: > 1 /busnum > 2 /busnum > 3 /busnum > 4 /busnum > 5 /busnum > 6 /busnum > 7 /busnum > 8 /busnum > 9 /busnum > 10 /busnum > [... ad infinitum ...] > > So it looks like it's already going wrong in the very first loop in the > BEGIN function. > > My sysfs looks fairly normal, nothing weird connected at all. And there > are only 7 hubs listed: > $ ls -d1 /sys/bus/usb/devices/usb* > /sys/bus/usb/devices/usb1 > /sys/bus/usb/devices/usb2 > /sys/bus/usb/devices/usb3 > /sys/bus/usb/devices/usb4 > /sys/bus/usb/devices/usb5 > /sys/bus/usb/devices/usb6 > /sys/bus/usb/devices/usb7 > > This is with gawk from Debian stable ("Lenny"): > $ gawk --version > GNU Awk 3.1.5 > Hi Franz - thank you very much for testing this. There was a operator precedence change between gawk 3.1.5 and my version 3.1.6 between the implicit concatenation operator and the pipe "|" operator. So I changed the piped parts to have explicit precedence, downloaded the old gawk and tested it. So now it should work for you too. > So it looks as if there's either a bug in 3.1.5, or you're doing something > that was not supported in that version. But allowing a script to run wild > in that way is not really good programming anyway I'd say. I agree. Testing is hard and regression testing is even harder. Thanks for your feedback. > BTW, did you test what happens with your script if /sys/bus/usb/devices/ > does not exist or when there are no hubs in it? I made sure that the > usb-devices script included some sanity checks for those cases. > I added an explicit exit in that case, thanks for the suggestion. Regards, Steve
Attachment:
usbd.awk
Description: Binary data