Skip to content

Commit 0078f5b

Browse files
author
shunevich.a
committed
prevent quotes duplication
1 parent 572130c commit 0078f5b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

build.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ func needsQuote(s string) bool {
247247
return true
248248
}
249249

250+
// if the string starts and ends with quotes, it is already quoted
251+
if strings.HasPrefix(s, "\"") && strings.HasSuffix(s, "\"") ||
252+
strings.HasPrefix(s, "'") && strings.HasSuffix(s, "'") {
253+
return false
254+
}
255+
250256
// lexer should throw an error when variable expansion syntax
251257
// is messed up, but just wrap it in quotes for now I guess
252258
var char rune

0 commit comments

Comments
 (0)