Skip to content

Commit

Permalink
expand: re-add slash conversion to globbing
Browse files Browse the repository at this point in the history
When we removed all uses of filepath.Join and thus filepath.Clean, we
forgot that Clean also performs FromSlash. We need that piece, because
we want globbing with forward slashes to work on Windows too.

This is useful so that a unix-like script with globbing also works on
Windows. There's no reason not to do that, since slashes are forbidden
from Windows file and directory names, anyway.

The regression was introduced in the previous commit, and is now fixed.
  • Loading branch information
mvdan committed Dec 16, 2018
1 parent 7d245b2 commit 5774069
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion expand/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,11 @@ func pathJoin2(elem1, elem2 string) string {
return elem1 + string(filepath.Separator) + elem2
}

// pathSplit is the opposite of pathJoin.
// pathSplit splits a file path into its elements, retaining empty ones. Before
// splitting, slashes are replaced with filepath.Separator, so that splitting
// Unix paths on Windows works as well.
func pathSplit(path string) []string {
path = filepath.FromSlash(path)
return strings.Split(path, string(filepath.Separator))
}

Expand Down

0 comments on commit 5774069

Please sign in to comment.