addlicense
addlicense copied to clipboard
add supporting wildcard in windows
Another alternative is to add a cmd line flag like -expand or -expand-glob, false by default. Then, Windows users can enable it explicitly, whenever needed.
On Sun, 22 Jul 2018, 12:03 Shiming Zhang, [email protected] wrote:
@wzshiming commented on this pull request.
In main.go https://github.com/google/addlicense/pull/6#discussion_r204234615:
@@ -95,7 +95,17 @@ type file struct { mode os.FileMode }
-func walk(ch chan<- *file, start string) { +func walk(ch chan<- *file, path string) {
- matches, _ := filepath.Glob(path)
Passed verbatim in a shell which supports expansion, this is a problem.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/google/addlicense/pull/6#discussion_r204234615, or mute the thread https://github.com/notifications/unsubscribe-auth/AABjPYKg1eQbZ7zYXT7Cs-DmGjMq_xn4ks5uJE3kgaJpZM4VT9tA .
If the use case here is 'addlicense *', then would a non-globbing work around would be 'addlicense .' ?
I realize that does help the case of more refined globs (e.g. *.js) but I also feel like using Powershell (or Cygwin) might be acceptable vs. having to build essentially another mode into this comment ("local file globbing") or jump through other hoops for a limited range of use cases. How bad would it be to document this as a limitation of using addlicense with the dos shell?
Another way to solve this is to move func walk or the matching algorithm into a separate file like walk.go and then have another one named walk_windows.go so that addlicense for Windows expands paths within the program and relies on a shell expansion otherwise. Or use build tags instead of _windows.go suffix.
This also needs to distinguish between shells, preferably only in the case of dos shell.
This also needs to distinguish between shells, preferably only in the case of dos shell.
I thought last time you said:
So I don't think you have to worry about the difference DOS vs PowerShell.
Or did you mean something else?
I got it wrong. no problem.