From e20353eeba4bcab1e7df41a9465b84a3329a7a9f Mon Sep 17 00:00:00 2001 From: pzx521521 Date: Wed, 16 Mar 2022 09:42:28 +0800 Subject: [PATCH] Update exec_windows.go change `hasSpace ` to `needsQuote` for better understanding --- src/syscall/exec_windows.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/syscall/exec_windows.go b/src/syscall/exec_windows.go index 98e4a887204..933f810a2bb 100644 --- a/src/syscall/exec_windows.go +++ b/src/syscall/exec_windows.go @@ -48,7 +48,7 @@ func appendEscapeArg(b []byte, s string) []byte { } needsBackslash := false - hasSpace := false + needsQuote := false for i := 0; i < len(s); i++ { if !needsBackslash{ switch s[i] { @@ -56,26 +56,26 @@ func appendEscapeArg(b []byte, s string) []byte { needsBackslash = true } } - if !hasSpace{ + if !needsQuote{ switch s[i] { case ' ', '\t', '!','&', '(', ')', '[', ']', '{', '}', ';', '<', '>', '|': - hasSpace = true + needsQuote = true } } } - if !needsBackslash && !hasSpace { + if !needsBackslash && !needsQuote { // No special handling required; normal case. return append(b, s...) } if !needsBackslash { - // hasSpace is true, so we need to quote the string. + // needsQuote is true, so we need to quote the string. b = append(b, '"') b = append(b, s...) return append(b, '"') } - if hasSpace { + if needsQuote { b = append(b, '"') } slashes := 0 @@ -94,7 +94,7 @@ func appendEscapeArg(b []byte, s string) []byte { } b = append(b, c) } - if hasSpace { + if needsQuote { for ; slashes > 0; slashes-- { b = append(b, '\\') }