github-actions-golang icon indicating copy to clipboard operation
github-actions-golang copied to clipboard

Warn about Pwsh quoting of Go commands arguments on Windows

Open dolmen opened this issue 3 years ago • 6 comments

I had the bad experience that this doesn't work on Windows:

      - name: Run coverage
        run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...

Output:

no required module provides package .out; to add it:
	go get .out
Error: Process completed with exit code 1.

But this works:

      - name: Run coverage
        run: go test -v -race -coverprofile coverage.out -covermode atomic ./...

The only difference is that = is replaced with space.

I suspect this is a PowerShell quoting issue.

dolmen avatar Apr 22 '22 12:04 dolmen

That is... interesting. When we add the warning, it would be good to also link to some docs explaining how the Powershell syntax conflicts with very simple POSIX shell without expansions or quoting.

mvdan avatar Apr 22 '22 12:04 mvdan

So far I found no document to confirm my hypothesis.

I only have experimental results:

dolmen avatar Apr 22 '22 13:04 dolmen

Those two pages from the PowerShell documentation don't mention something special about - args.

(the second one tells about --% that allows to block processing of the rest of the command line, but I don' see how it could be used to have portable commands shared between Unix and Windows).

dolmen avatar Apr 22 '22 13:04 dolmen

Nothing mentioned about = in the About parameters page either.

dolmen avatar Apr 22 '22 13:04 dolmen

In fact the default shell on Windows is Pwsh (Powershell Core).

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

dolmen avatar Apr 22 '22 13:04 dolmen

--% works (on Windows):

      - name: Run coverage
        run: go --% test -v -race -coverprofile=coverage.out -covermode=atomic ./...

dolmen avatar Apr 22 '22 14:04 dolmen