On Tue, Mar 22, 2005 at 04:58:54PM +0100, Baptiste Malguy wrote:
> Package: discover
> Version: 2.0.7-2
> 
> discover-modprobe will not load modules with a name that is a substring of a 
> previously loaded module.
> 
> Example: e1000 and e100
> 
> If an Intel Gigabit Ethernet card (module e1000) is detected before an
> Intel Fast Ethernet one (e100), the module e1000 is loaded first.
> The module e100 will not be loaded because "e100" is a substring of
> "e1000".
> 
> Here is a so small patch to fix this.

[snip]

> -    echo ${module_details_uniq} | grep ${module_info} > /dev/null 2>&1
> +    echo ${module_details_uniq} | egrep -e 
> "^(.*[[:space:]])?${module_info}([[:space:]].*)?$" > /dev/null 2>&1

For portability, we should say grep -E instead of "egrep".

Also, since you're explicitly anchoring the pattern, it is guaranteed to
not start with "-", so you don't the -e option.

If I'm understanding the problem, there's a simpler way to
express what you want -- tell grep to match with an implicit word
boundary.

Finally, you probably want to literally match the module name.  While I
don't think any real-world Linux kernel modules have regular express
metacharacters in them, it's generally good to cater to one's defensive
programming instincts.  This suggests usage of grep -F instead of grep
-E.

All of the above would make the patch:

> -    echo ${module_details_uniq} | grep ${module_info} > /dev/null 2>&1
> +    echo ${module_details_uniq} | grep -Fw "$module_info" > /dev/null 2>&1

The braces around the variable name are not necessary.  The quotes
around the shell variable expansiion are useful in the event the module
name has embedded whitespace in it.  (Again, unlikely, but wise to guard
against.)

Thanks for your report!

-- 
Branden Robinson          | GPG signed/encrypted mail welcome
[EMAIL PROTECTED]       | 1024D/9C0BCBFB
Progeny Linux Systems     | D5F6 D4C9 E25B 3D37 068C
                          | 72E8 0F42 191A 9C0B CBFB


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to