HMCL
HMCL copied to clipboard
CommandBuilder: Use more robust quoting
trafficstars
- A while ago I brewed a pretty good quoting thing with unit tests on CMD (https://github.com/Artoria2e5/node/blob/fix!/child-process-args/test/parallel/test-child-process-spawnsync-shell-args.js). Use that. Specifically, the batch language and MSVCRT interprets the whole quoted thing a bit differently and we need to quote for both.
- An example that I know breaks is
"He\\\\o \\\"Wor\tld\\|<>&*\\"(java string). 这个按老方法 escape 出来是"He\\\o \\"Wor ld\|<>&*\"(raw string),cmd 没记错的话会认为重定向,但是新方法的"He\\o \\""Wor ld\|<>&*\\"不会。另外 cmd 测试起来很烦,内置echo和外置程序行为不同,上面的测试用例是用node -e写了一个小的替换。
- An example that I know breaks is
- The shell quote is overcomplicated. The correct way is a lot like PWSH, in that we have a simple single quote.
Bash 单引号内不支持任何转义,包括对单引号本身的转义。你需要证明你对 parseBash 的更改是正确的。
Bash 单引号内不支持任何转义,包括对单引号本身的转义。你需要证明你对 parseBash 的更改是正确的。
对,所以把它换成:
'关闭单引号环境。\'正常环境转义。'打开继续单引号。
可以参考 python shlex.quote,同样的道理,但是用双引号包中间的单引号:https://github.com/python/cpython/blob/3.10/Lib/shlex.py#L334
不愿意 merge upstream,因为名字不如我改得好。<_<
@Artoria2e5 冲突了!快来修
xjb 改名!
Checkstyle 炸喽 @Artoria2e5 哈哈哈,Java CI 也炸了
到处改名指望手动网页 merge 能找全本来就是扯淡……