From 1297ec97d29b680778c2c985a6a9e2d693af764b Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Tue, 7 Mar 2017 10:28:37 -0500 Subject: net-setup: Fix zero argument mode The grepped output of 'ifconfig -a' included a colon after each interface. This broke subsequent calls for information on the interface. Also, instead of flashing an error when a path did not exist, check that it does exist before calling basename. Skip sit0 as it cannot be configured. Finally, check the return value of the dialog call. Only zero means an interface was selected to be processed. --- net-setup | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/net-setup b/net-setup index d47628b..f106f46 100755 --- a/net-setup +++ b/net-setup @@ -7,7 +7,7 @@ get_ifbus() { # Example: ../../../../bus/pci (wanted: pci) # Example: ../../../../../../bus/usb (wanted: usb) local if_bus=$(readlink /sys/class/net/${iface}/device/subsystem) - basename ${if_bus} + [[ -e "${if_bus}" ]] && basename ${if_bus} } get_ifproduct() { @@ -57,7 +57,7 @@ get_ifdriver() { # Example: ../../../bus/pci/drivers/forcedeth (wanted: forcedeth) local if_driver=$(readlink /sys/class/net/${iface}/device/driver) - basename ${if_driver} + [[ -e "${if_driver}" ]] && basename ${if_driver} } get_ifmac() { @@ -98,19 +98,17 @@ show_ifmenu() { local opts IFS=" " - for ifname in $(ifconfig -a | grep "^[^ ]"); do + for ifname in $(ifconfig -a | grep "^[^ ]" | cut -d : -f 1); do ifname="${ifname%% *}" [[ ${ifname} == "lo" ]] && continue + [[ ${ifname} == "sit0" ]] && continue opts="${opts} ${ifname} '$(get_ifdesc ${ifname})'" done IFS="${old_ifs}" - if ! eval dialog --visit-items \ + dialog --visit-items --trim \ --menu "Please select the interface that you wish to configure from the list below:" 0 0 0 $opts 2>iface - then - exit - fi - + [[ $? -gt 0 ]] && exit iface=$(< iface) } -- cgit v1.2.3-18-g5258