From 4b08d5748828c4dd4a5e846ac9ad853c37a65488 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 18 Aug 2017 15:32:30 +0200 Subject: [PATCH] wireless networks: Only delete one network at a time Destroying multiple networks in one go is not really a good idea here, since error codes are not properly passed on. Signed-off-by: Michael Tremer --- src/functions/functions.wireless-networks | 37 +++++++++++------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/functions/functions.wireless-networks b/src/functions/functions.wireless-networks index 0133fe7f..e2af14cd 100644 --- a/src/functions/functions.wireless-networks +++ b/src/functions/functions.wireless-networks @@ -236,26 +236,25 @@ wireless_network_new() { fi } -# Function that deletes based on the passed parameters -# one ore more wireless networks +# Deletes a wireless network wireless_network_destroy() { - local ssid - for ssid in "$@"; do - local ssid_hash="$(wireless_network_hash "${ssid}")" - assert isset ssid_hash - - if ! wireless_network_exists "${ssid}"; then - log ERROR "The wireless network ${ssid} does not exist." - continue - fi - - log DEBUG "Deleting wireless network ${ssid}" - - if ! rm -rf "${NETWORK_WIRELESS_NETWORKS_DIR}/${ssid_hash}"; then - log ERROR "Deleting the wireless network ${ssid} was not sucessful" - return ${EXIT_ERROR} - fi - done + local ssid="${1}" + + if ! wireless_network_exists "${ssid}"; then + error "No such wireless network: ${ssid}" + return ${EXIT_ERROR} + fi + + local ssid_hash="$(wireless_network_hash "${ssid}")" + assert isset ssid_hash + + if ! rm -rf "${NETWORK_WIRELESS_NETWORKS_DIR}/${ssid_hash}"; then + error "Could not delete the wireless network" + return ${EXIT_ERROR} + fi + + log INFO "Successfully destroyed wireless network ${ssid}" + return ${EXIT_OK} } wireless_network_encryption_mode() { -- 2.39.2