From 55b64854b263856eab838d58cf9b28ce67756de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 9 Apr 2023 22:56:24 +0800 Subject: [PATCH] update --- execute.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/execute.go b/execute.go index 0e669fd..9be929e 100644 --- a/execute.go +++ b/execute.go @@ -11,7 +11,6 @@ import ( "errors" "os" "os/exec" - "strings" "time" "git.zhangdeman.cn/zhangdeman/command/define" @@ -64,7 +63,11 @@ func Execute(workDir string, command string, param []string) *define.Result { cmdInstance := exec.Command(command, param...) cmdInstance.Dir = result.WorkDir result.Output, result.Error = cmdInstance.CombinedOutput() - result.Output = []byte(strings.TrimRight(string(result.Output), `\n`)) + if len(result.Output) >= 2 { + if string(result.Output[len(result.Output)-1]) == "n" && string(result.Output[len(result.Output)-2]) == "\\" { + result.Output = result.Output[0 : len(result.Output)-2] + } + } return result }