diff options
author | Ted Trask <ttrask01@yahoo.com> | 2015-01-12 16:11:26 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2015-01-12 16:11:26 +0000 |
commit | af55ecb73277b61a8642fc6bea091291ecc926bf (patch) | |
tree | 4b5eceb2c44db9cf2e73ae9a93d62905821d681a /config/delete_device.lua | |
parent | 207a204bb95ceba5017a91c340b53ef12c0811d8 (diff) | |
download | acf-provisioning-af55ecb73277b61a8642fc6bea091291ecc926bf.tar.bz2 acf-provisioning-af55ecb73277b61a8642fc6bea091291ecc926bf.tar.xz |
Remove setfenv call for Lua 5.2 compatibility
Diffstat (limited to 'config/delete_device.lua')
-rw-r--r-- | config/delete_device.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/config/delete_device.lua b/config/delete_device.lua index edf9cf2..59c8c89 100644 --- a/config/delete_device.lua +++ b/config/delete_device.lua @@ -50,11 +50,17 @@ for name,val in pairs(params.value) do end -- Then call the other script +local f local env = {} setmetatable (env, {__index = _G}) --- loadfile loads into the global environment --- so we set env 0, not env 1 -setfenv (0, env) -local f = loadfile("/etc/provisioning/update_device_params.lua") +local IS_52_LOAD = pcall(load, '') +if IS_52_LOAD then + f = loadfile("/etc/provisioning/update_device_params.lua", "bt", env) +else + -- loadfile loads into the global environment + -- so we set env 0, not env 1 + setfenv (0, env) + f = loadfile("/etc/provisioning/update_device_params.lua") + setfenv (0, _G) +end if (f) then f(functions, params, oldparams) end -setfenv (0, _G) |