From 623b46fb8eaa6523298aae56df2875eaa666a2e3 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Sat, 20 Mar 2021 22:00:39 -0400 Subject: [PATCH] fix: dont include quotes in cmd arguments, so my commits are fixed now lmaoooo --- main.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 714553a..8f250af 100644 --- a/main.go +++ b/main.go @@ -69,14 +69,24 @@ func main() { if err == nil { continue } quoted := false - q := func(r rune) bool { + cmdArgs := []string{} + sb := &strings.Builder{} + + for _, r := range cmdString { if r == '"' { quoted = !quoted + // dont add back quotes + //sb.WriteRune(r) + } else if !quoted && r == ' ' { + cmdArgs = append(cmdArgs, sb.String()) + sb.Reset() + } else { + sb.WriteRune(r) } - return !quoted && r == ' ' } - - cmdArgs := strings.FieldsFunc(cmdString, q) + if sb.Len() > 0 { + cmdArgs = append(cmdArgs, sb.String()) + } if len(cmdArgs) == 0 { continue }