Do wildcard globbing on Windows (#1362)

* Glob wildcards on Windows

* test/cases/globbing/0001
This commit is contained in:
John Kerl 2023-08-19 17:40:35 -04:00 committed by GitHub
parent 793f52c470
commit 9d1d2e07ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 1 deletions

View file

@ -11,6 +11,7 @@ package platform
import (
"fmt"
"os"
"path/filepath"
"strings"
shellquote "github.com/kballard/go-shellquote"
@ -76,7 +77,20 @@ func GetArgs() []string {
}
}
//printArgs(retargs, "NEW")
return retargs
globbed := make([]string, 0)
for i, _ := range retargs {
// Expand things like *.csv
matches, err := filepath.Glob(retargs[i])
if matches != nil && err == nil {
globbed = append(globbed, matches...)
} else {
globbed = append(globbed, retargs[i])
}
}
//printArgs(globbed, "NEW")
return globbed
}
// ----------------------------------------------------------------

View file

@ -0,0 +1,2 @@
a,b,c
1,2,3
1 a b c
2 1 2 3

View file

@ -0,0 +1,2 @@
a,b,c
4,5,6
1 a b c
2 4 5 6

View file

@ -0,0 +1 @@
mlr --c2p cat ${CASEDIR}/*.csv

View file

View file

@ -0,0 +1,3 @@
a b c
1 2 3
4 5 6