Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do wildcard globbing on Windows #1362

Merged
merged 2 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion internal/pkg/platform/getargs_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package platform
import (
"fmt"
"os"
"path/filepath"
"strings"

shellquote "github.com/kballard/go-shellquote"
Expand Down Expand Up @@ -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
}

// ----------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions test/cases/globbing/0001/a.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a,b,c
1,2,3
2 changes: 2 additions & 0 deletions test/cases/globbing/0001/b.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a,b,c
4,5,6
1 change: 1 addition & 0 deletions test/cases/globbing/0001/cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mlr --c2p cat ${CASEDIR}/*.csv
Empty file added test/cases/globbing/0001/experr
Empty file.
3 changes: 3 additions & 0 deletions test/cases/globbing/0001/expout
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a b c
1 2 3
4 5 6
Loading