diff --git a/res/miracle-utils.sh b/res/miracle-utils.sh index e77fff0..12186c5 100755 --- a/res/miracle-utils.sh +++ b/res/miracle-utils.sh @@ -52,7 +52,7 @@ function find_wireless_connected_network_interfaces { # function find_physical_for_network_interface { PHY_INDEX=$(iw dev $1 info | grep wiphy | awk '{print $2}') - if [ -n $PHY_INDEX ] + if [ -n "$PHY_INDEX" ] then echo phy$PHY_INDEX fi @@ -65,6 +65,12 @@ function search_p2p_capabilities { WI_DEVICE=$1 PHY_DEVICE=$(find_physical_for_network_interface $WI_DEVICE) + if [ -z "$PHY_DEVICE" ] + then + echo "cannot find physical device for $WI_DEVICE" + return + fi + if iw phy $PHY_DEVICE info | grep -Pzo "(?s)Supported interface modes.*Supported commands" | grep "P2P" &> /dev/null then echo $WI_DEVICE supports P2P diff --git a/res/test-hardware-capabilities.sh b/res/test-hardware-capabilities.sh index f3bab45..1e227f5 100755 --- a/res/test-hardware-capabilities.sh +++ b/res/test-hardware-capabilities.sh @@ -14,12 +14,16 @@ fi . miracle-utils.sh -WIFI_NAMES=$(find_wireless_network_interfaces) -WIFI_COUNT=$(echo "$WIFI_NAMES" | wc -l) +WIFI_COUNT=0 +WIFI_NAMES="$(find_wireless_network_interfaces)" +if [ -n "$WIFI_NAMES" ] +then + WIFI_COUNT=$(echo "$WIFI_NAMES" | wc -l) +fi if [ 0 = $WIFI_COUNT ] then - echo There is no wireless devices avaliable + echo There is no wireless devices available exit 1 elif [ 1 = $WIFI_COUNT ] then