go-shellwords
go-shellwords copied to clipboard
Avoid treating \ as escape char on Windows
Fixes #38
While this is probably not a perfect solution, I think it makes a good start as it makes all tests pass on Windows and fixes the most common issue when \
paths are used in the input.
I originally wanted to implement proper escaping for Windows too, but then I realized it would be a little more complex and I thought this is already a progress. 🤷♂️
Codecov Report
Merging #39 into master will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## master #39 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 143 145 +2
=========================================
+ Hits 143 145 +2
Impacted Files | Coverage Δ | |
---|---|---|
shellwords.go | 100.00% <100.00%> (ø) |
|
util_posix.go | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 28e4fdf...74d265b. Read the comment docs.
it is not good that isEscapeRune always return false.
I agree @mattn - as I mentioned above this is rather simple solution which is just addressing the known \
case.
I can look into more complete solution, but I expect it to be much more complex than this, because escaping on Windows seems to be more context-dependent, so it's not as simple as declaring a single rune as escape character I'm afraid, unless I misread the available docs on this. Also escaping behaviours may differ between cmd.exe and PowerShell.
Either way if you are willing to review/discuss better Windows support I can look into it.
Hey, how can I help getting this merged in? We have a replace in our go.mod for almost a year now 😬
refs https://github.com/goreleaser/goreleaser/issues/2080
Hi @mattn @radeksimko, any plans on moving this PR forward? Seems like someone over at #38 have confirmed that this fix works. Would be great to have this feature in this package!
@jamestiotio I've been using a fork in @goreleaser for a while now: https://github.com/caarlos0/go-shellwords
It would be nicer if @mattn could merge this though