Over one year gone I found a bug in your patch: for the if method, you need to add " | grep -v deprecated" to the filter of the ip command. BTW, wise decision to use ip rather than ifconfig: you have no chance with the former, afaik.
Cheers and thanks for the patch! Andreas.