返回 DeepSeek-Reasonix
bash_cmdline_windows.go
根目录 / internal / tool / builtin / bash_cmdline_windows.go
1 //go:build windows
2
3 package builtin
4
5 import (
6 "syscall"
7 "unicode/utf16"
8 )
9
10 // windowsCommandLineMax is CreateProcessW's lpCommandLine ceiling in UTF-16
11 // code units, the terminating NUL included.
12 const windowsCommandLineMax = 32767
13
14 // commandLineUnits counts the UTF-16 units os/exec hands CreateProcessW for
15 // argv, NUL included, using the same per-argument escaping it applies.
16 func commandLineUnits(argv []string) (int, int) {
17 units := 1
18 for i, arg := range argv {
19 if i > 0 {
20 units++
21 }
22 units += len(utf16.Encode([]rune(syscall.EscapeArg(arg))))
23 }
24 return units, windowsCommandLineMax
25 }
26
26 lines GO