fix(netconf): accept interface number as input, not just name
User sees a numbered list but could only type the name. Now numeric input is resolved to the interface name via awk NR==N. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,11 +13,22 @@ for iface in $IFACES; do
|
|||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
done
|
done
|
||||||
echo ""
|
echo ""
|
||||||
printf "Interface name [or Enter to pick first]: "
|
printf "Interface number or name [Enter = first]: "
|
||||||
read IFACE
|
read INPUT
|
||||||
if [ -z "$IFACE" ]; then
|
|
||||||
|
if [ -z "$INPUT" ]; then
|
||||||
IFACE=$(echo "$IFACES" | head -1)
|
IFACE=$(echo "$IFACES" | head -1)
|
||||||
|
elif echo "$INPUT" | grep -qE '^[0-9]+$'; then
|
||||||
|
# Numeric input — resolve to name
|
||||||
|
IFACE=$(echo "$IFACES" | awk "NR==$INPUT")
|
||||||
|
if [ -z "$IFACE" ]; then
|
||||||
|
echo "Error: no interface with number $INPUT"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
IFACE="$INPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Selected: $IFACE"
|
echo "Selected: $IFACE"
|
||||||
echo ""
|
echo ""
|
||||||
echo " 1) DHCP"
|
echo " 1) DHCP"
|
||||||
|
|||||||
Reference in New Issue
Block a user