From b124d4c1b8a42a728e6bce5ce82a920df8c1c24d Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Mon, 18 Apr 2016 11:55:39 +0800 Subject: [PATCH] skynet.getenv can return empty string --- lualib/skynet.lua | 7 +------ service/bootstrap.lua | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lualib/skynet.lua b/lualib/skynet.lua index 94db8b5e..463048fe 100644 --- a/lualib/skynet.lua +++ b/lualib/skynet.lua @@ -343,12 +343,7 @@ function skynet.exit() end function skynet.getenv(key) - local ret = c.command("GETENV",key) - if ret == "" then - return - else - return ret - end + return c.command("GETENV",key) end function skynet.setenv(key, value) diff --git a/service/bootstrap.lua b/service/bootstrap.lua index db8d8581..90a542cb 100644 --- a/service/bootstrap.lua +++ b/service/bootstrap.lua @@ -4,15 +4,15 @@ require "skynet.manager" -- import skynet.launch, ... local memory = require "memory" skynet.start(function() - local sharestring = tonumber(skynet.getenv "sharestring") - memory.ssexpand(sharestring or 4096) + local sharestring = tonumber(skynet.getenv "sharestring" or 4096) + memory.ssexpand(sharestring) local standalone = skynet.getenv "standalone" local launcher = assert(skynet.launch("snlua","launcher")) skynet.name(".launcher", launcher) - local harbor_id = tonumber(skynet.getenv "harbor") + local harbor_id = tonumber(skynet.getenv "harbor" or 0) if harbor_id == 0 then assert(standalone == nil) standalone = true