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

pwsh -Login support #10050

Merged
merged 44 commits into from Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ca6e8c0
First attempt
rjmholt Jun 14, 2019
33519b4
Move -Login parsing out to Program.cs
rjmholt Jun 26, 2019
43cf25a
Fix merge bug
rjmholt Jun 26, 2019
9d7137c
Fix login params
rjmholt Jun 26, 2019
53e698e
Fix and speed up login logic
rjmholt Jul 2, 2019
025b22c
Document startup code
rjmholt Jul 3, 2019
ff4de63
Remove -LoadProfile from implementation
rjmholt Jul 3, 2019
95c29a6
Make -Login *nix-specific
rjmholt Jul 3, 2019
d371d6b
Add no-op -Login to Windows
rjmholt Jul 3, 2019
0571e5a
Remove loadprofile add login tests
rjmholt Jul 3, 2019
965c0ff
Fix tests
rjmholt Jul 3, 2019
137f267
Use /bin/bash on macOS
rjmholt Jul 4, 2019
abda72e
Fix arguments
rjmholt Jul 4, 2019
8638d4e
Fix tests
rjmholt Jul 4, 2019
023746e
Add login methods to UNIX block
rjmholt Jul 4, 2019
e20a16e
Fix endif placement
rjmholt Jul 5, 2019
17b63ec
Move login dummy switch to alpha position
rjmholt Jul 5, 2019
a8636f2
Remove debug code
rjmholt Jul 5, 2019
9c49ed1
Use zsh instead of bash on macOS
rjmholt Jul 5, 2019
d09f6c2
Switch back to bash
rjmholt Jul 6, 2019
964eaeb
Move back to zsh
rjmholt Jul 8, 2019
e97369d
Make arg help consistent with online help
rjmholt Jul 9, 2019
96594d3
Identify - for login
rjmholt Jul 12, 2019
be073a3
Simplify and polish
rjmholt Jul 12, 2019
3b15bba
Remove unused p/invoke
rjmholt Jul 12, 2019
8cf5c8a
Remove unsupported exec -a use
rjmholt Jul 12, 2019
c123a4f
Fixup calls and comments
rjmholt Jul 12, 2019
3353537
Add test for -pwsh login invocation
rjmholt Jul 12, 2019
d242340
Fix syntax and comment errors
rjmholt Jul 12, 2019
7b0e08e
Add tests
rjmholt Jul 12, 2019
6e2937a
Address @SteveL-MSFT's comments
rjmholt Jul 12, 2019
b78528a
ifdef exception/constants
rjmholt Jul 12, 2019
9371bd0
Fix casing
rjmholt Jul 12, 2019
6f54ead
Fix syntax error
rjmholt Jul 12, 2019
581d7e0
Use env var to prevent needless login check
rjmholt Aug 8, 2019
336dc89
Address @daxian-dbw's comments
rjmholt Aug 8, 2019
09c424a
Add comment about setenv use
rjmholt Aug 8, 2019
147d2a7
Add -Help exclusion
rjmholt Aug 8, 2019
826d945
Add detection of /?
rjmholt Aug 8, 2019
50429fb
Update comments a bit
daxian-dbw Aug 8, 2019
07e248c
Amend login logic to read only first argument
rjmholt Aug 8, 2019
1d8e1c5
Update a stale comment about `exec -a`
daxian-dbw Aug 8, 2019
da0f75f
Update tests
rjmholt Aug 8, 2019
4b1f521
Address remaining comments
daxian-dbw Aug 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -183,7 +183,7 @@ internal class CommandLineParameterParser
"file",
rjmholt marked this conversation as resolved.
Show resolved Hide resolved
rjmholt marked this conversation as resolved.
Show resolved Hide resolved
rjmholt marked this conversation as resolved.
Show resolved Hide resolved
rjmholt marked this conversation as resolved.
Show resolved Hide resolved
rjmholt marked this conversation as resolved.
Show resolved Hide resolved
SteveL-MSFT marked this conversation as resolved.
Show resolved Hide resolved
SteveL-MSFT marked this conversation as resolved.
Show resolved Hide resolved
SteveL-MSFT marked this conversation as resolved.
Show resolved Hide resolved
SteveL-MSFT marked this conversation as resolved.
Show resolved Hide resolved
SteveL-MSFT marked this conversation as resolved.
Show resolved Hide resolved
"help",
"inputformat",
"loadprofile",
"login",
"noexit",
"nologo",
"noninteractive",
Expand Down Expand Up @@ -710,21 +710,23 @@ private void ParseHelper(string[] args)
_noExit = false;
break;
}
else if (MatchSwitch(switchKey, "help", "h") || MatchSwitch(switchKey, "?", "?"))

if (MatchSwitch(switchKey, "help", "h") || MatchSwitch(switchKey, "?", "?"))
{
_showHelp = true;
_showExtendedHelp = true;
_abortStartup = true;
}
else if (MatchSwitch(switchKey, "login", "l"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should move this to the bottom, since the check will never succeed and all switches below it will check this first.

But I left it here because of alpha ordering and also because I feel like it might be worth doing a wider investigation of the switch detection logic for startup performance.

{
// This handles -Login on Windows only, where it does nothing.
// On *nix, -Login is handled much earlier to improve startup performance.
}
else if (MatchSwitch(switchKey, "noexit", "noe"))
{
_noExit = true;
noexitSeen = true;
}
else if (MatchSwitch(switchKey, "loadprofile", "l"))
{
_skipUserInit = false;
}
else if (MatchSwitch(switchKey, "noprofile", "nop"))
{
_skipUserInit = true;
Expand Down
Expand Up @@ -125,14 +125,14 @@ https://aka.ms/powershell
Type 'help' to get help.</value>
</data>
<data name="UsageHelp" xml:space="preserve">
<value>Usage: pwsh[.exe] [[-File] &lt;filePath&gt; [args]]
<value>Usage: pwsh[.exe] [-Login] [[-File] &lt;filePath&gt; [args]]
[-Command { - | &lt;script-block&gt; [-args &lt;arg-array&gt;]
| &lt;string&gt; [&lt;CommandParameters&gt;] } ]
[-ConfigurationName &lt;string&gt;] [-CustomPipeName &lt;string&gt;]
[-EncodedCommand &lt;Base64EncodedCommand&gt;]
[-ExecutionPolicy &lt;ExecutionPolicy&gt;] [-InputFormat {Text | XML}]
[-Interactive] [-LoadProfile] [-MTA] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile]
[-OutputFormat {Text | XML}] [-SettingsFile &lt;filePath&gt;] [-STA] [-Version]
[-Interactive] [-MTA] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile]
[-OutputFormat {Text | XML}] [-SettingsFile &lt;filePath&gt;] [-STA] [-Version]
[-WindowStyle &lt;style&gt;] [-WorkingDirectory &lt;directoryPath&gt;]

pwsh[.exe] -h | -Help | -? | /?
Expand Down Expand Up @@ -293,10 +293,13 @@ All parameters are case-insensitive.</value>
Present an interactive prompt to the user. Inverse for NonInteractive
parameter.

-LoadProfile | -l
-Login | -l

Load the PowerShell profiles. This is the default behavior even if this is
not specified.
On Linux and macOS, starts PowerShell as a login shell,
daxian-dbw marked this conversation as resolved.
Show resolved Hide resolved
using /bin/sh to execute login profiles such as /etc/profile and ~/.profile.
On Windows, this switch does nothing.

Note that "-Login" is only supported as the first parameter to pwsh.

-MTA

Expand Down