go-shellwords icon indicating copy to clipboard operation
go-shellwords copied to clipboard

Avoid treating \ as escape char on Windows

Open radeksimko opened this issue 4 years ago • 6 comments

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. 🤷‍♂️

radeksimko avatar May 30 '20 21:05 radeksimko

Codecov Report

Merging #39 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            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.

codecov-commenter avatar May 30 '20 21:05 codecov-commenter

it is not good that isEscapeRune always return false.

mattn avatar Aug 28 '20 15:08 mattn

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.

radeksimko avatar Aug 28 '20 15:08 radeksimko

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

caarlos0 avatar Feb 24 '21 18:02 caarlos0

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 avatar Nov 21 '22 17:11 jamestiotio

@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

caarlos0 avatar Nov 21 '22 19:11 caarlos0