summaryrefslogtreecommitdiff
path: root/xmake/core/base/os.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-07-10 21:28:04 +0800
committerruki <[email protected]>2016-07-10 21:28:04 +0800
commitc0a237b461bb03a73f3ba93c1f6b1637f3d613ce (patch)
treec39c2b7e7d0445986bb93276135e2d493726c6bc /xmake/core/base/os.lua
parent6f0ee30871bde957f6923bdad95ac1c10a39fda3 (diff)
fix the current directory changed when building
Diffstat (limited to 'xmake/core/base/os.lua')
-rw-r--r--xmake/core/base/os.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 61e19cd84..ae93103eb 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -318,6 +318,11 @@ function os.exec(cmd, outfile, errfile)
local waitok = -1
local status = -1
if coroutine.running() then
+
+ -- save the current directory
+ local curdir = os.curdir()
+
+ -- wait it
repeat
-- poll it
waitok, status = process.wait(proc, 0)
@@ -325,6 +330,9 @@ function os.exec(cmd, outfile, errfile)
coroutine.yield()
end
until waitok ~= 0
+
+ -- resume the current directory
+ os.cd(curdir)
else
waitok, status = process.wait(proc, -1)
end
@@ -354,13 +362,21 @@ function os.execv(shellname, argv, outfile, errfile)
local waitok = -1
local status = -1
if coroutine.running() then
+
+ -- save the current directory
+ local curdir = os.curdir()
+
+ -- wait it
repeat
-- poll it
- waitok, status = process.wait(prpoc, 0)
+ waitok, status = process.wait(proc, 0)
if waitok == 0 then
coroutine.yield()
end
until waitok ~= 0
+
+ -- resume the current directory
+ os.cd(curdir)
else
waitok, status = process.wait(proc, -1)
end