Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How should I construct this?



On Apr 24,  2:16pm, TJ Luoma wrote:
}
} I thought about trying to make an array or something like this where the 
} first 'column' would be the SSID and the 2nd column would be the 
} passwords

In addition to Thomas's hashtables remarks, zsh "for" also supports
populating multiple variables each pass around the loop.

So if you have an ordinary array like your example (BTW I hope those
aren't your real passwords) then you can do

	for SSID WIFIPASS in $ALL_WIFI_NETWORKS
	do
		# Attempt to join network $SSID using $WIFIPASS
	done

If you declare ALL_WIFI_NETWORKS as a hash table as Thomas suggested, then
you can still do

	for SSID WIFIPASS in ${(kv)ALL_WIFI_NETWORKS}
	do
		# ...
	done

but the SSID probably won't be in the same order as you assigned them,
because hashes return their values in hash bucket order.  If you need
to preserve a fixed ordering, you have to use a real array.



Messages sorted by: Reverse Date, Date, Thread, Author