diff options
author | 2017-03-07 10:28:37 -0500 | |
---|---|---|
committer | 2017-03-07 10:34:04 -0500 | |
commit | 1297ec97d29b680778c2c985a6a9e2d693af764b (patch) | |
tree | f44929aeb9aff4ac4db00957632028df7a9f5bf4 | |
parent | autoconfig: EVMS is long dead. (diff) | |
download | livecd-tools-1297ec97d29b680778c2c985a6a9e2d693af764b.tar.gz livecd-tools-1297ec97d29b680778c2c985a6a9e2d693af764b.tar.bz2 livecd-tools-1297ec97d29b680778c2c985a6a9e2d693af764b.zip |
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.
-rwxr-xr-x | net-setup | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -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) } |