From 98465fbe2b038aa5c0234b2d69201fabe0de0450 Mon Sep 17 00:00:00 2001 From: Jake Bolton Date: Thu, 4 Jul 2024 11:49:31 -0500 Subject: [PATCH] add terms to no-loc and add new example (#11234) Add missing metadata to no-loc for CommandWithArgs, and fix example for launching from cmd.exe --- .../About/about_Pwsh.md | 22 ++++++++++++++++++- .../About/about_Pwsh.md | 22 ++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Pwsh.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Pwsh.md index 681e43ac2658..e0fcac5d5853 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Pwsh.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Pwsh.md @@ -2,7 +2,7 @@ description: Explains how to use the `pwsh` command-line interface. Displays the command-line parameters and describes the syntax. Locale: en-US ms.date: 01/10/2024 -no-loc: [-File, -f, -Command, -c, -ConfigurationName, -config, -CustomPipeName, -EncodedCommand, -e, -ec, -ExecutionPolicy, -ex, -ep, -InputFormat, -inp, -if, -Interactive, -i, -Login, -l, -MTA, -NoExit, -noe, -NoLogo, -nol, -NonInteractive, -noni, -NoProfile, -nop, -OutputFormat, -o, -of, -SettingsFile, -settings, -SSHServerMode, -sshs, -STA, -Version, -v, -WindowStyle, -w, -WorkingDirectory, -wd, -Help] +no-loc: [-File, -f, -Command, -c, -CommandWithArgs, -cwa, -ConfigurationName, -config, -CustomPipeName, -EncodedCommand, -e, -ec, -ExecutionPolicy, -ex, -ep, -InputFormat, -inp, -if, -Interactive, -i, -Login, -l, -MTA, -NoExit, -noe, -NoLogo, -nol, -NonInteractive, -noni, -NoProfile, -nop, -OutputFormat, -o, -of, -SettingsFile, -settings, -SSHServerMode, -sshs, -STA, -Version, -v, -WindowStyle, -w, -WorkingDirectory, -wd, -Help] online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_pwsh?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: about Pwsh @@ -221,6 +221,25 @@ arg: arg1 arg: arg2 ``` +> [!NOTE] +> [Argument parsing with quotes][05] causes the example to fail if ran from +> `cmd.exe` or `powershell.exe`. To run from those, you can use + +```powershell +# When ran from cmd.exe +pwsh -CommandWithArgs "$args | % { ""arg: $_"" }" arg1 arg2 + +# when ran from pwsh.exe +pwsh -CommandWithArgs '$args | % { "arg: $_" }' arg1 arg2 + +# when ran from powershell.exe +pwsh -CommandWithArgs '"$args | % { ""arg: $_"" }"' arg1 arg2 + +# when ran from pwsh.exe with legacy argument passing +$PSNativeCommandArgumentPassing = 'Legacy' +pwsh -CommandWithArgs '$args | % { ""arg: $_"" }' arg1 arg2 +``` + ### -ConfigurationName | -config Specifies a configuration endpoint in which PowerShell is run. This can be any @@ -410,3 +429,4 @@ prepend the command parameters with a hyphen (`-`), not a forward slash (`/`). [02]: about_Automatic_Variables.md#lastexitcode [03]: about_operators.md#special-operators [04]: https://linux.die.net/man/1/chsh +[05]: about_Parsing.md#passing-arguments-that-contain-quote-characters \ No newline at end of file diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Pwsh.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Pwsh.md index 29659c1b1964..dcf68ff3f143 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Pwsh.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Pwsh.md @@ -2,7 +2,7 @@ description: Explains how to use the `pwsh` command-line interface. Displays the command-line parameters and describes the syntax. Locale: en-US ms.date: 01/10/2024 -no-loc: [-File, -f, -Command, -c, -ConfigurationName, -config, -CustomPipeName, -EncodedCommand, -e, -ec, -ExecutionPolicy, -ex, -ep, -InputFormat, -inp, -if, -Interactive, -i, -Login, -l, -MTA, -NoExit, -noe, -NoLogo, -nol, -NonInteractive, -noni, -NoProfile, -nop, -OutputFormat, -o, -of, -SettingsFile, -settings, -SSHServerMode, -sshs, -STA, -Version, -v, -WindowStyle, -w, -WorkingDirectory, -wd, -Help] +no-loc: [-File, -f, -Command, -c, -CommandWithArgs, -cwa, -ConfigurationName, -config, -CustomPipeName, -EncodedCommand, -e, -ec, -ExecutionPolicy, -ex, -ep, -InputFormat, -inp, -if, -Interactive, -i, -Login, -l, -MTA, -NoExit, -noe, -NoLogo, -nol, -NonInteractive, -noni, -NoProfile, -nop, -OutputFormat, -o, -of, -SettingsFile, -settings, -SSHServerMode, -sshs, -STA, -Version, -v, -WindowStyle, -w, -WorkingDirectory, -wd, -Help] online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_pwsh?view=powershell-7.5&WT.mc_id=ps-gethelp schema: 2.0.0 title: about Pwsh @@ -221,6 +221,25 @@ arg: arg1 arg: arg2 ``` +> [!NOTE] +> [Argument parsing with quotes][05] causes the example to fail if ran from +> `cmd.exe` or `powershell.exe`. To run from those, you can use + +```powershell +# When ran from cmd.exe +pwsh -CommandWithArgs "$args | % { ""arg: $_"" }" arg1 arg2 + +# when ran from pwsh.exe +pwsh -CommandWithArgs '$args | % { "arg: $_" }' arg1 arg2 + +# when ran from powershell.exe +pwsh -CommandWithArgs '"$args | % { ""arg: $_"" }"' arg1 arg2 + +# when ran from pwsh.exe with legacy argument passing +$PSNativeCommandArgumentPassing = 'Legacy' +pwsh -CommandWithArgs '$args | % { ""arg: $_"" }' arg1 arg2 +``` + ### -ConfigurationName | -config Specifies a configuration endpoint in which PowerShell is run. This can be any @@ -410,3 +429,4 @@ prepend the command parameters with a hyphen (`-`), not a forward slash (`/`). [02]: about_Automatic_Variables.md#lastexitcode [03]: about_operators.md#special-operators [04]: https://linux.die.net/man/1/chsh +[05]: about_Parsing.md#passing-arguments-that-contain-quote-characters \ No newline at end of file