Changeset

9332:048389a9bbd4

mod_admin_telnet: Split out sort function for clarity
author Matthew Wild <mwild1@gmail.com>
date Fri, 21 Sep 2018 14:37:47 +0100
parents 9331:2f634cc02eac
children 9333:fd704adc62e1
files plugins/mod_admin_telnet.lua
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua	Fri Sep 21 14:37:18 2018 +0100
+++ b/plugins/mod_admin_telnet.lua	Fri Sep 21 14:37:47 2018 +0100
@@ -404,12 +404,14 @@
 	return ok, (ok and "Module unloaded from "..count.." host"..(count ~= 1 and "s" or "")) or ("Last error: "..tostring(err));
 end
 
+local function _sort_hosts(a, b)
+	if a == "*" then return true
+	elseif b == "*" then return false
+	else return a < b; end
+end
+
 function def_env.module:reload(name, hosts)
-	hosts = array.collect(get_hosts_set(hosts, name)):sort(function (a, b)
-		if a == "*" then return true
-		elseif b == "*" then return false
-		else return a < b; end
-	end);
+	hosts = array.collect(get_hosts_set(hosts, name)):sort(_sort_hosts)
 
 	-- Reload the module for each host
 	local ok, err, count = true, nil, 0;