diff options
| author | ruki <[email protected]> | 2022-09-13 23:41:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-09-13 23:41:27 +0800 |
| commit | fcaad7a606e45a64ceb6eb5236b6d751b5801c0f (patch) | |
| tree | f1184af3a070cb8aef7d7c8db93cff544bcb3c7d /xmake/core/base/os.lua | |
| parent | 1bf418b749afd4abaeaf36574569e6ac4fc4b8d9 (diff) | |
support os.execv with {shell = true}
Diffstat (limited to 'xmake/core/base/os.lua')
| -rw-r--r-- | xmake/core/base/os.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 592e4d2a8..38ef683bf 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -746,6 +746,28 @@ function os.execv(program, argv, opt) end end + -- run shell file? parse `#!/usr/bin/env bash` in xx.sh + -- + -- e.g. os.execv("./configure", {"--help"}) => os.execv("/usr/bin/env", {"bash", "./configure", "--help"}) + if opt.shell and os.isfile(filename) then + local shellfile = filename + 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) + end + table.insert(shellargv, shellfile) + table.join2(shellargv, argv) + argv = shellargv + end + file:close() + end + -- uses the given environments? local envs = nil if opt.envs then |
