Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseCommand Some command parsing and processing exceptions under Windows #3370

Closed
hailaz opened this issue Mar 13, 2024 · 4 comments
Closed
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@hailaz
Copy link
Member

hailaz commented Mar 13, 2024

v2.6.4 gf build用到以下功能

例如在Windows下使用gproc.ShellExec(ctx, cmd)
执行命令git log -1 --format="%cd %H" --date=format:"%Y-%m-%d %H:%M:%S"--format="%cd %H"参数会被切割开
导致报错

fatal: ambiguous argument '%H"': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

func parseCommand(cmd string) (args []string) {

@hailaz hailaz added the bug It is confirmed a bug, but don't worry, we'll handle it. label Mar 13, 2024
@Issues-translate-bot Issues-translate-bot changed the title parseCommand 在Windows下的某些命令解析处理异常 parseCommand Some command parsing and processing exceptions under Windows Mar 13, 2024
@wln32
Copy link
Member

wln32 commented Mar 14, 2024

如果是windows系统的话,是否可以在process.NewProcess的函数里面添加一个判断,在初始化process后面,直接使用原生的参数不经过处理

	process.SysProcAttr = &syscall.SysProcAttr{}
	process.SysProcAttr.CmdLine = path + " " + gstr.Join(args, " ")

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


If it is a windows system, is it possible to add a judgment in the function of process.NewProcess? After initializing the process, use the native parameters directly without processing.

process.SysProcAttr = &syscall.SysProcAttr{}
process.SysProcAttr.CmdLine = path + " " + gstr.Join(args, " ")  
      

@wln32
Copy link
Member

wln32 commented Mar 14, 2024

如果是windows系统的话,是否可以在process.NewProcess的函数里面添加一个判断,在初始化process后面,直接使用原生的参数不经过处理

	process.SysProcAttr = &syscall.SysProcAttr{}
	process.SysProcAttr.CmdLine = path + " " + gstr.Join(args, " ")

需要把parseCmd函数处理下,直接返回cmd即可

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


If it is a Windows system, is it possible to add a judgment in the process.NewProcess function, and directly use the native parameters without processing after initializing the process?

process.SysProcAttr = &syscall.SysProcAttr{}
process.SysProcAttr.CmdLine = path + " " + gstr.Join(args, " ")

You need to process the parseCmd function and return cmd directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

3 participants