[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#495676: hw-detect: hw-detect new device detection misbehaves with wlan* devices



> I tried to dig the history of the repository in order to figure out why
> snapshot_dev() used "sort" in the first place, but I was not able to
> get any meaningful result.  Do anyone have an idea?

The reason for the sort is probably to make the dialog show:
eth0: .........
eth1: .........
wlan0: .........

instead of what I get on my HP 2510p without the sort:
eth0: .........
wlan0: .........
eth1: .........

I must say I'd prefer to not depend on sort orders at all and with the 
removal of the sort statement you still depend implicitly on the sort 
order of /proc/net/dev.

Instead of the proposed sed statement I'd propose to write out 
compare_devs() and just check all devices in a loop, for example 
(untested):
        local olddevs="$1"
        local devs="$2"
	local newdevs, dev

	newdevs=
	for dev in $olddevs; do
		if ! echo "$devs" | grep -Eq "(^| )$dev( |$)"; then
			newdevs="${newdevs:+$newdevs }$dev"
		fi
	done
	echo "$newdevs"

A bit slower, but that does not really matter here. And it's a lot more 
readable than either current code or the proposed sed statement.

Note that ethdetect is rather obsolete anyway. It still basically assumes 
that modules need to be loaded manually instead of being automatically 
loaded by the kernel/udev...



Reply to: