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))
|
||||
done
|
||||
echo ""
|
||||
printf "Interface name [or Enter to pick first]: "
|
||||
read IFACE
|
||||
if [ -z "$IFACE" ]; then
|
||||
printf "Interface number or name [Enter = first]: "
|
||||
read INPUT
|
||||
|
||||
if [ -z "$INPUT" ]; then
|
||||
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
|
||||
else
|
||||
IFACE="$INPUT"
|
||||
fi
|
||||
|
||||
echo "Selected: $IFACE"
|
||||
echo ""
|
||||
echo " 1) DHCP"
|
||||
|
||||
Reference in New Issue
Block a user