diff options
| author | ruki <[email protected]> | 2019-04-27 00:38:08 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-04-26 21:48:53 +0800 |
| commit | 2fc83b38a2aa6c5dc80efe89d7b3864b356cf412 (patch) | |
| tree | aa68362b868c815fca24201c33d187cb47a06e44 /xmake/core/base/os.lua | |
| parent | af03058084d45e4d1c437a2f43205cf69c2b93ec (diff) | |
improve serenvp
Diffstat (limited to 'xmake/core/base/os.lua')
| -rw-r--r-- | xmake/core/base/os.lua | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 65852b22c..82ff8fcf0 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -935,33 +935,32 @@ end -- set values to environment variable function os.setenv(name, ...) - local seperator = os.host() == "windows" and ';' or ':' - return os._setenv(name, table.concat({...}, seperator)) + return os._setenv(name, table.concat({...}, path.envsep())) end -- add values to environment variable function os.addenv(name, ...) - local seperator = os.host() == "windows" and ';' or ':' + local sep = path.envsep() local values = {...} if #values > 0 then - return os._setenv(name, table.concat(values, seperator) .. seperator .. (os.getenv(name) or "")) + return os._setenv(name, table.concat(values, sep) .. sep .. (os.getenv(name) or "")) else return os.getenv(name) end end -- set values to environment variable with the given seperator -function os.setenvp(name, values, seperator) - seperator = seperator or (os.host() == "windows" and ';' or ':') - return os._setenv(name, table.concat(table.wrap(values), seperator)) +function os.setenvp(name, values, sep) + sep = sep or path.envsep() + return os._setenv(name, table.concat(table.wrap(values), sep)) end -- add values to environment variable with the given seperator -function os.addenvp(name, values, seperator) - seperator = seperator or (os.host() == "windows" and ';' or ':') +function os.addenvp(name, values, sep) + sep = sep or path.envsep() values = table.wrap(values) if #values > 0 then - return os._setenv(name, table.concat(values, seperator) .. seperator .. (os.getenv(name) or "")) + return os._setenv(name, table.concat(values, sep) .. sep .. (os.getenv(name) or "")) else return os.getenv(name) end |
