cleaned up code a bit

This commit is contained in:
inxi-svn 2011-04-30 19:14:27 +00:00
parent 021299a5d8
commit 6df9f15527

12
inxi
View file

@ -3413,14 +3413,18 @@ get_network_advanced_data()
usb_product=$( cut -d ':' -f 2 <<< $usb_data )
# this grep returns the path plus the contents of the file, with a colon separator, so slice that off
# /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/idVendor
working_path=$( grep -s "$usb_vendor" /sys/devices/pci*/*/usb*/*/*/idVendor | sed -e "s/idVendor:$usb_vendor//" -e '/driver/d' )
working_path=$( grep -s "$usb_vendor" /sys/devices/pci*/*/usb*/*/*/idVendor | \
sed -e "s/idVendor:$usb_vendor//" -e '/driver/d' )
# try an alternate path if first one doesn't work
# /sys/devices/pci0000:00/0000:00:0b.1/usb1/1-1/idVendor
if [[ -z $working_path ]];then
working_path=$( grep -s "$usb_vendor" /sys/devices/pci*/*/usb*/*/idVendor | sed -e "s/idVendor:$usb_vendor//" -e '/driver/d' )
product_path=$( grep -s "$usb_product" /sys/devices/pci*/*/usb*/*/idProduct | sed -e "s/idProduct:$usb_product//" -e '/driver/d' )
working_path=$( grep -s "$usb_vendor" /sys/devices/pci*/*/usb*/*/idVendor | \
sed -e "s/idVendor:$usb_vendor//" -e '/driver/d' )
product_path=$( grep -s "$usb_product" /sys/devices/pci*/*/usb*/*/idProduct | \
sed -e "s/idProduct:$usb_product//" -e '/driver/d' )
else
product_path=$( grep -s "$usb_product" /sys/devices/pci*/*/usb*/*/*/idProduct | sed -e "s/idProduct:$usb_product//" -e '/driver/d' )
product_path=$( grep -s "$usb_product" /sys/devices/pci*/*/usb*/*/*/idProduct | \
sed -e "s/idProduct:$usb_product//" -e '/driver/d' )
fi
# make sure it's the right product/vendor match here, it will almost always be but let's be sure