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

about_Pwsh.md is missing no-loc terms for CommandWithArgs and clarify cmd.exe error #11234

Closed
3 tasks done
ninmonkey opened this issue Jul 4, 2024 · 1 comment · Fixed by #11235
Closed
3 tasks done
Labels
issue-doc-bug Issue - error in documentation needs-triage Waiting - Needs triage

Comments

@ninmonkey
Copy link
Contributor

Prerequisites

  • Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
  • Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Typo in Get-Foo cmdlet" instead of "Typo."
  • Verify Version: If there is a mismatch between documentation and the behavior on your system, ensure that the version you are using is the same as the documentation. Check this box if they match or the issue you are reporting is not version specific.

Links

Summary

1] The no-loc metadata is missing the Command -CommandWithArgs and its alias -cwa

2] The example given works, but only when it's launched from a pwsh.exe but not cmd.exe or powershell.exe

I thought the cmd.exe and powershell.exe cases were common enough to be worth mentioning.

Details

For completion here's fixes for all 4 cases:

# When ran from cmd.exe
# ( the original throws )
pwsh -CommandWithArgs "$args | % { ""arg: $_"" }" arg1 arg2

# from a pwsh session with default values
# ( the original works )
pwsh -CommandWithArgs '$args | % { "arg: $_" }' arg1 arg2

# ran from a  powershell.exe session 5.1
# ( the original outputs blank ) 
pwsh -CommandWithArgs '"$args | % { ""arg: $_"" }"' arg1 arg2

# from a pwsh session using legacy argument passing
# ( the original outputs blank )
$PSNativeCommandArgumentPassing = 'Legacy'
pwsh -CommandWithArgs '$args | % { ""arg: $_"" }' arg1 arg2

Tested using pwsh 7.4.2 and powershell 5.1

Suggested Fix

Maybe Part 2 should simplify to the info link about_parsing#passing-arguments-that-contain-quote-characters

  • The final example with Legacy could be assumed knowledge, and left out.

I included examples because common cases fail. Some show no errors. That could be confusing for users


Part 3 I am not sure if this is correct behavior or possibly a bug? The lack of syntax error is what originally triggered these tests.

# start a new pwsh -nop session, then 
$PSNativeCommandArgumentPassing = 'legacy'
pwsh -nop -CommandWithArgs '$args | % { "arg: $_" }' arg1 arg2
# no errors, no output. 
@ninmonkey ninmonkey added issue-doc-bug Issue - error in documentation needs-triage Waiting - Needs triage labels Jul 4, 2024
ninmonkey added a commit to ninmonkey/PowerShell-Docs that referenced this issue Jul 4, 2024
Add missing metadata to no-loc for CommandWithArgs, and fix example for launching from cmd.exe
@sdwheeler
Copy link
Contributor

Part 3 I am not sure if this is correct behavior or possibly a bug? The lack of syntax error is what originally triggered these tests.

Please file an issue with the PowerShell team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue-doc-bug Issue - error in documentation needs-triage Waiting - Needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants