vesta/func/ip.sh
The code seems to have a bug in the get_ip_iface function -causing incorrect calculation of the n variable, which is used to determine the interface number. This bug can lead to incorrect interface names being returned.
fix? Instead of adding 1 to the i variable, we should increment i by 1. This will ensure that the correct interface number is calculated.
get_ip_iface() {
i=$(/sbin/ip addr |grep -w $interface |\
awk '{print $NF}' |tail -n 1 |cut -f 2 -d
if [ "$i" = "$interface" ]; then
n=0
else
n=$((i + 1))
fi
echo "$interface:$n"
}