diff options
| author | ruki <[email protected]> | 2022-09-16 00:43:42 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-09-16 00:43:42 +0800 |
| commit | 70dad3d816b657aab6ef678aac385cc726f16c4f (patch) | |
| tree | cffbfda38c6ea8e872b1eb0a21856fb63e963ad8 | |
| parent | 84ebe5e4ab403f5359537a2f463c159a843087e7 (diff) | |
improve os.exec with shell
| -rw-r--r-- | xmake/core/base/os.lua | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 38ef683bf..0cf133491 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -754,16 +754,23 @@ function os.execv(program, argv, opt) local file = io.open(filename, 'r') local head = file:read("l") if head and head:startswith("#!") then - head = head:sub(3) - local shellargv = {} - local splitinfo = head:split("%s") - filename = splitinfo[1] - if #splitinfo > 1 then - shellargv = table.slice(splitinfo, 2) + -- we cannot run /bin/sh directly on msys2/cygwin + local subhost = os.subhost() + if subhost == "msys" or subhost == "cygwin" then + filename = "sh" + argv = table.join(shellfile, argv) + else + head = head:sub(3) + local shellargv = {} + local splitinfo = head:split("%s") + filename = splitinfo[1] + if #splitinfo > 1 then + shellargv = table.slice(splitinfo, 2) + end + table.insert(shellargv, shellfile) + table.join2(shellargv, argv) + argv = shellargv end - table.insert(shellargv, shellfile) - table.join2(shellargv, argv) - argv = shellargv end file:close() end |
