summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-29 23:52:17 +0800
committerruki <[email protected]>2020-04-29 17:13:44 +0800
commitdcb9bf2b3ad1248fbe1ac472a4b851dc841067a9 (patch)
treedf0ded62efcfb04b9676536217ad66ba26d2de5b /core/src
parentcf92ed9d8ed9d833458ffcb94466f7b7c32c91b7 (diff)
fix os.args
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/os/args.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/core/src/xmake/os/args.c b/core/src/xmake/os/args.c
index aabede414..abe5aebd1 100644
--- a/core/src/xmake/os/args.c
+++ b/core/src/xmake/os/args.c
@@ -33,7 +33,7 @@
/* //////////////////////////////////////////////////////////////////////////////////////
* private implementation
*/
-static tb_void_t tb_os_args_append(tb_string_ref_t result, tb_char_t const* cstr, tb_size_t size, tb_bool_t escape)
+static tb_void_t tb_os_args_append(tb_string_ref_t result, tb_char_t const* cstr, tb_size_t size, tb_bool_t escape, tb_bool_t nowrap)
{
// check
tb_assert_and_check_return(size < TB_PATH_MAXN);
@@ -60,7 +60,7 @@ static tb_void_t tb_os_args_append(tb_string_ref_t result, tb_char_t const* cstr
buff[n] = '\0';
// wrap "" if exists escape characters and spaces?
- if (wrap_quote)
+ if (wrap_quote && !nowrap)
{
tb_string_chrcat(result, '\"');
tb_size_t i = 0;
@@ -90,13 +90,24 @@ tb_int_t xm_os_args(lua_State* lua)
tb_bool_t escape = tb_false;
if (lua_istable(lua, 2))
{
- // is detached?
+ // is escape?
lua_pushstring(lua, "escape");
lua_gettable(lua, 2);
escape = lua_toboolean(lua, -1);
lua_pop(lua, 1);
}
+ // disable to wrap quote characters in global?
+ tb_bool_t nowrap = tb_false;
+ if (lua_istable(lua, 2))
+ {
+ // is nowrap?
+ lua_pushstring(lua, "nowrap");
+ lua_gettable(lua, 2);
+ nowrap = lua_toboolean(lua, -1);
+ lua_pop(lua, 1);
+ }
+
// init result
tb_string_t result;
tb_string_init(&result);
@@ -117,7 +128,7 @@ tb_int_t xm_os_args(lua_State* lua)
size_t size = 0;
tb_char_t const* cstr = luaL_checklstring(lua, -1, &size);
if (cstr && size)
- tb_os_args_append(&result, cstr, size, escape);
+ tb_os_args_append(&result, cstr, size, escape, nowrap);
lua_pop(lua, 1);
}
}
@@ -126,7 +137,7 @@ tb_int_t xm_os_args(lua_State* lua)
size_t size = 0;
tb_char_t const* cstr = luaL_checklstring(lua, 1, &size);
if (cstr && size)
- tb_os_args_append(&result, cstr, size, escape);
+ tb_os_args_append(&result, cstr, size, escape, nowrap);
}
// return result