Hi Dan,

Spent some time looking at this more closely, and it looks like it's a little more subtle than I originally thought. The problem is that the busybox shell evaluates the environmental variables slightly differently than the normal shell. The result is that for %k = usbdev1.2

X=%k X=${X#usbdev} B=${X%%.*} D=${X#*.}; echo bus/usb/$B/$D
   produces
bus/usb//

X=%k; X=${X#usbdev} B=${X%%.*} D=${X#*.}; echo bus/usb/$B/$D
   produces
bus/usb/usbdev1/2

X=%k; X=${X#usbdev}; B=${X%%.*} D=${X#*.}; echo bus/usb/$B/$D
   produces
bus/usb/1/2

Thus the smallest change is the third version adding the two ;'s. This behaviour seems fairly consistant across a number of versions of busybox including the most recent stable version and the current development version. I'm tempted to say this is a bug in busybox's shell so I'll post there, but I'd still suggest making the change to the udev rules to cover all the angles.

Cheers,

Tony.

Dan Nicholson wrote:
On 7/13/06, Bruce Dubbs <[EMAIL PROTECTED]> wrote:
From: Anthony Wright <[EMAIL PROTECTED]>
The udev-config rules do not work with the busybox /bin/sh, the patch
below corrects this.
[snip]
diff --new-file -urp udev-config-20060515.orig/25-lfs.rules
udev-config-20060515/25-lfs.rules
--- udev-config-20060515.orig/25-lfs.rules    2006-05-03
06:19:59.000000000 +0100
+++ udev-config-20060515/25-lfs.rules 2006-07-11 14:28:11.000000000 +0100
@@ -84,7 +84,7 @@ KERNEL=="djs",        MODE="0644"

# USB devices go in their own subdirectory

-SUBSYSTEM=="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev}
B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", NAME="%c"
+SUBSYSTEM=="usb_device", PROGRAM="/bin/sh -c 'echo %k | /bin/sed
s-usbdev-bus/usb/- | /bin/sed s-\\.-/-'", NAME="%c"
KERNEL=="hiddev*",                    NAME="usb/%k"
KERNEL=="auer*",                    NAME="usb/%k"
KERNEL=="legousbtower*",                NAME="usb/%k"

Tony (if you get this), do you know why that command fails with
busybox /bin/sh? Seems one thing that's kind of shady is that X is
setting and referencing itself in the same command. The command right
now is (in shell)

X=%k X=${X#usbdev} B=${X%%.*} D=${X#*.}; echo bus/usb/$B/$D

It seems safer to me if it was

X=%k; X=${X#usbdev} B=${X%%.*} D=${X#*.}; echo bus/usb/$B/$D

Notice the semicolon after the first X=. In fact, that's consistent in
the other distros if they're using the rules distributed in the udev
tarball (RedHat does).

Actually, it seems that all the distros are also using printf instead
of echo, but that's probably not important here.

Would you try out the above fix on busybox? Even the horrid /bin/sh on
our HP-UX server at work could handle that. I'm curious what part of
the commands busybox /bin/sh can't handle.

--
Dan

--
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to