From 2c23deaf9c1e321e0f906dc6336ba50cabbae7a2 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 25 Aug 2022 12:37:24 +0200 Subject: [PATCH] unet-cli: pass service object to set_service() Avoids accessing global net_data from within the function Signed-off-by: Felix Fietkau --- scripts/unet-cli | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/unet-cli b/scripts/unet-cli index 96894a3..f00c817 100755 --- a/scripts/unet-cli +++ b/scripts/unet-cli @@ -227,9 +227,7 @@ function set_host(name) { }); } -function set_service(name) { - let service = net_data.services[name]; - +function set_service(service) { set_fields(service, { type: "string", members: "array", @@ -388,12 +386,12 @@ case 'add-service': members: [], }; assert(args.type, "Missing service type"); - set_service(servicename); + set_service(net_data.services[servicename]); break; case 'set-service': assert(net_data.services[servicename], `Service '${servicename}' does not exist`); - set_service(servicename); + set_service(net_data.services[servicename]); break; default: -- 2.30.2