Skip to content

Commit 0ad0244

Browse files
committed
Error "The system cannot find the file specified" when trying to convert filenames with commas #4
1 parent 31b78f9 commit 0ad0244

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ _Example:_
8181
```shell
8282
--params="param1:value1, param2:value2, param3:value3"
8383
```
84+
Comma `,` inside the parameter value must be escaped with `\,`.
85+
8486

8587
##### File parameter
8688

build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#/bin/bash
22

3-
GOOS=linux GOARCH=amd64 go build -o bin/convertapi
3+
GOOS=linux GOARCH=amd64 GO111MODULE=auto go build -o ./bin/convertapi
44
zip -q -j -m -9 bin/convertapi_lin.zip bin/convertapi
55

6-
GOOS=linux GOARCH=arm go build -o bin/convertapi
6+
GOOS=linux GOARCH=arm GO111MODULE=auto go build -o bin/convertapi
77
zip -q -j -m -9 bin/convertapi_lin_arm.zip bin/convertapi
88

9-
GOOS=windows GOARCH=amd64 go build -o bin/convertapi.exe
9+
GOOS=windows GOARCH=amd64 GO111MODULE=auto go build -o bin/convertapi.exe
1010
zip -q -j -m -9 bin/convertapi_win.zip bin/convertapi.exe
1111

12-
GOOS=darwin GOARCH=amd64 go build -o bin/convertapi
12+
GOOS=darwin GOARCH=amd64 GO111MODULE=auto go build -o bin/convertapi
1313
zip -q -j -m -9 bin/convertapi_mac.zip bin/convertapi

params.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import (
1414
func parseParams(paramString string, ext string) (paramsets [][]param.IParam, err error) {
1515
var newParams []param.IParam
1616
var parallel bool
17-
for _, p := range strings.Split(paramString, ",") {
17+
const esc = "|escapedcomma|"
18+
var escParamStr = strings.ReplaceAll(paramString, "\\,", esc)
19+
for _, p := range strings.Split(escParamStr, ",") {
1820
kv := strings.SplitN(p, ":", 2)
1921
k := strings.TrimSpace(kv[0])
20-
v := strings.TrimSpace(kv[1])
22+
v := strings.ReplaceAll(strings.TrimSpace(kv[1]), esc, ",")
2123
if newParams, parallel, err = newCaParams(k, v, ext); err != nil {
2224
return
2325
}

0 commit comments

Comments
 (0)