]> xenbits.xensource.com Git - people/royger/freebsd.git/commitdiff
In awk, casting a variable as a boolean condition is the same as testing if
authordteske <dteske@FreeBSD.org>
Mon, 12 Dec 2016 21:29:48 +0000 (21:29 +0000)
committerdteske <dteske@FreeBSD.org>
Mon, 12 Dec 2016 21:29:48 +0000 (21:29 +0000)
the length of the variable contents is greater than zero

This allows us to also move the secondary condition into the action clause

usr.sbin/bsdinstall/scripts/wlanconfig

index 2239388bcbf8214bbc08ad45fe44713477ef55c6..cde3c901bca741bb464cc2e9dcf45d0fce58df2e 100755 (executable)
@@ -213,10 +213,7 @@ while :; do
 
        SCAN_RESULTS=$( wpa_cli scan_results )
        NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' '
-               /..:..:..:..:..:../ {
-                       if (length($5) > 0)
-                               printf("\"%s\"\t%s\n", $5, $4)
-               }
+               /..:..:..:..:..:../ && $5 { printf("\"%s\"\t%s\n", $5, $4) }
        ' | sort | uniq )
 
        if [ ! "$NETWORKS" ]; then