addlicense icon indicating copy to clipboard operation
addlicense copied to clipboard

add supporting wildcard in windows

Open wzshiming opened this issue 7 years ago • 6 comments

wzshiming avatar Jul 18 '18 05:07 wzshiming

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 .

x1ddos avatar Jul 22 '18 10:07 x1ddos

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?

mco-gh avatar Jul 22 '18 15:07 mco-gh

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.

x1ddos avatar Dec 18 '19 17:12 x1ddos

This also needs to distinguish between shells, preferably only in the case of dos shell.

wzshiming avatar Dec 19 '19 03:12 wzshiming

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?

x1ddos avatar Dec 19 '19 09:12 x1ddos

I got it wrong. no problem.

wzshiming avatar Dec 19 '19 09:12 wzshiming