diff options
| author | ruki <[email protected]> | 2020-03-25 22:47:48 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-03-25 10:46:52 +0800 |
| commit | 357c8504a1421dff16e3c7edc54959efd75f6654 (patch) | |
| tree | 3080c3bbd28d856925df38c2a88ff85f29a95f3b | |
| parent | 6cea9b08790ce55bc278c0567ac0b1d00f896707 (diff) | |
improve os.args
| m--------- | core/src/tbox/tbox | 0 | ||||
| -rw-r--r-- | core/src/xmake/os/args.c | 4 | ||||
| -rw-r--r-- | tests/modules/os/test.lua | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox -Subproject ee9ecebbd0d86a513cf3ccf521bf302685f9469 +Subproject 2ad3d467643f5029d2ff5d520a4ff19188e5849 diff --git a/core/src/xmake/os/args.c b/core/src/xmake/os/args.c index 419e6db54..567d70d30 100644 --- a/core/src/xmake/os/args.c +++ b/core/src/xmake/os/args.c @@ -47,10 +47,10 @@ static tb_void_t tb_os_args_append(tb_string_ref_t result, tb_char_t const* cstr tb_size_t m = tb_arrayn(buff); while ((ch = *p) && n < m) { + // escape '"' if (ch == '\"') { if (n < m) buff[n++] = '\\'; - wrap_quote = tb_true; } else if (ch == ' ' || ch == '(' || ch == ')') wrap_quote = tb_true; if (n < m) buff[n++] = ch; @@ -59,7 +59,7 @@ static tb_void_t tb_os_args_append(tb_string_ref_t result, tb_char_t const* cstr tb_assert_and_check_return(n < m); buff[n] = '\0'; - // wrap "" and escape '\\' if exists escape characters and spaces? + // wrap "" if exists escape characters and spaces? if (wrap_quote) { tb_string_chrcat(result, '\"'); diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua index 02be4778b..2f008edd0 100644 --- a/tests/modules/os/test.lua +++ b/tests/modules/os/test.lua @@ -69,6 +69,7 @@ function test_argv(t) t:are_equal(os.argv("aa\\bb/cc dd"), {"aa\\bb/cc", "dd"}) t:are_equal(os.argv("\"aa\\\\bb/cc dd\" ee"), {"aa\\bb/cc dd", "ee"}) t:are_equal(os.argv("\"aa\\\\bb/cc (dd)\" ee"), {"aa\\bb/cc (dd)", "ee"}) + t:are_equal(os.argv("-D__prefix__=\\\"tbox\\\""), {"-D__prefix__=\"tbox\""}) end function test_args(t) @@ -79,4 +80,5 @@ function test_args(t) t:are_equal(os.args({"aa\\bb/cc", "dd"}), "aa\\bb/cc dd") t:are_equal(os.args({"aa\\bb/cc dd", "ee"}), "\"aa\\\\bb/cc dd\" ee") t:are_equal(os.args({"aa\\bb/cc (dd)", "ee"}), "\"aa\\\\bb/cc (dd)\" ee") + t:are_equal(os.args("-D__prefix__=\"tbox\""), "-D__prefix__=\\\"tbox\\\"") end |
