-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Interactive input should works with -File parameter #9494
Description
Come form #9362
The comment in code says that interactive input should works
-
with -File:
PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs
Lines 1133 to 1141 in ceed73d
// Process interactive input... if (args[i] == "-") { // the arg to -file is -, which is secret code for "read the commands from stdin with prompts" _explicitReadCommandsFromStdin = true; _noPrompt = false; } else -
with -Command:
PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs
Lines 1296 to 1304 in ceed73d
else if (args[i] == "-") { // the arg to -command is -, which is secret code for "read the commands from stdin with no prompts" _explicitReadCommandsFromStdin = true; _noPrompt = true; ++i; if (i != args.Length)
The comments differ in "no prompts" vs "with prompts" - it is not clear is it comments and behaviors right.
Also using dash is documented only for -Command (not for -File)
https://docs.microsoft.com/en-us/powershell/scripting/components/console/powershell.exe-command-line-help?view=powershell-6#-command
Steps to reproduce
pwsh -file C:\temp\q1.ps1 -Expected behavior
pwsh -file C:\1\q1.ps1 -
<wait interactive inout>
Actual behavior
pwsh -file C:\1\q1.ps1 -
-
Expected behavior
pwsh -command -
<wait interactive inout>
Actual behavior
'-' was specified as the argument to -Command but standard input has not been redirected for this process.
Usage: pwsh[.exe] [[-File] <filePath> [args]]
[-Command { - | <script-block> [-args <arg-array>]
| <string> [<CommandParameters>] } ]
[-ConfigurationName <string>] [-CustomPipeName <string>]
[-EncodedCommand <Base64EncodedCommand>]
[-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}]
[-Interactive] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile]
[-OutputFormat {Text | XML}] [-Version] [-WindowStyle <style>]
[-WorkingDirectory <directoryPath>]
pwsh[.exe] -h | -Help | -? | /?
PowerShell Online Help https://aka.ms/pscore6-docs
All parameters are case-insensitive.
-
Environment data
Name Value
---- -----
PSVersion 6.2.0-rc.1
PSEdition Core
GitCommitId 6.2.0-rc.1-204-g262d86c691519ff7d5adacbae6424e2c87accce6
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0