GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pwsh -Login support by rjmholt · Pull Request #10050 · PowerShell/PowerShell

pwsh -Login support #10050

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.

Sign up for GitHub

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

Merged
Andrew (anmenaga) merged 44 commits into PowerShell:master from rjmholt:exec-login
Aug 14, 2019

Uh oh!

There was an error while loading. Please reload this page.

Merged

pwsh -Login support #10050

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

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

14 changes: 8 additions & 6 deletions 14 src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ internal class CommandLineParameterParser
"file",
Comment thread
rjmholt marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread
rjmholt marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread
rjmholt marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread
rjmholt marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread
rjmholt marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread
SteveL-MSFT marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread
SteveL-MSFT marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread
SteveL-MSFT marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread
SteveL-MSFT marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread
SteveL-MSFT marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

"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"))
Comment thread Outdated

@rjmholt Rob Holt (rjmholt) Jul 9, 2019

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ExE-Boss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
{
// 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
15 changes: 9 additions & 6 deletions 15 src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
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,
Comment thread
daxian-dbw marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

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
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.