Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about Pwsh quoting of Go commands arguments on Windows #24

Open
dolmen opened this issue Apr 22, 2022 · 6 comments
Open

Warn about Pwsh quoting of Go commands arguments on Windows #24

dolmen opened this issue Apr 22, 2022 · 6 comments

Comments

@dolmen
Copy link

dolmen commented Apr 22, 2022

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.

@mvdan
Copy link
Owner

mvdan commented Apr 22, 2022

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.

@dolmen
Copy link
Author

dolmen commented Apr 22, 2022

So far I found no document to confirm my hypothesis.

I only have experimental results:

@dolmen
Copy link
Author

dolmen commented Apr 22, 2022

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
Copy link
Author

dolmen commented Apr 22, 2022

Nothing mentioned about = in the About parameters page either.

@dolmen dolmen changed the title Warn about Powershell quoting of Go commands arguments Warn about Pwsh quoting of Go commands arguments on Windows Apr 22, 2022
@dolmen
Copy link
Author

dolmen commented Apr 22, 2022

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 added a commit to dolmen-go/sqlfunc that referenced this issue Apr 22, 2022
Powershell Core seems to have issues with parameter
"-coverprofile=coverage.out".

The failure I'm fixing:

$ go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
no required module provides package .out; to add it:
	go get .out

See mvdan/github-actions-golang#24
@dolmen
Copy link
Author

dolmen commented Apr 22, 2022

--% works (on Windows):

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants