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

Windows error: flag provided but not defined: -encodedCommand #217

Closed
anmathew opened this issue Oct 27, 2023 · 3 comments
Closed

Windows error: flag provided but not defined: -encodedCommand #217

anmathew opened this issue Oct 27, 2023 · 3 comments

Comments

@anmathew
Copy link

anmathew commented Oct 27, 2023

PS C:\Users\user1> date | .\goawk.exe {'print $1'}
flag provided but not defined: -encodedCommand

PS C:\Users\user1> date | .\goawk.exe '{print $1}'
Thursday,

If the quotes are inside the curlies {}, it complains about flag provided but not defined: -encodedCommand

@benhoyt
Copy link
Owner

benhoyt commented Oct 27, 2023

Hi @anmathew, I think you'll find that the first format (with the quotes inside the curlies) isn't correct, on either Windows/Powershell or Linux. The second example is correct: use a single-quoted string to include the entire AWK program (the curlies are part of the AWK source).

In the first example, Powershell must be passing -encodedCommand as a command argument to GoAWK, hence the error message.

@benhoyt benhoyt closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
@anmathew
Copy link
Author

Thanks for the reply.

$ date | awk '{print $1}'
Fri
$ date | awk {'print $1'}
Fri

Both formats work on Linux, it would be great if the same behavior works on Windows too.

@benhoyt
Copy link
Owner

benhoyt commented Oct 28, 2023

Sorry @anmathew, but this is a shell quoting issue -- a difference in how Powershell vs Unix shells handle argument parsing and quoting (not a Windows vs Linux thing as such). The quotes outside the curlies is how everyone does it and works fine on both platforms, so I recommend just using that.

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