Skip to content

Add -Login startup option #2400

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

Merged
merged 6 commits into from
Jan 10, 2020
Merged

Conversation

rjmholt
Copy link
Contributor

@rjmholt rjmholt commented Jan 2, 2020

PR Summary

Resolves #2384.

Adds a config setting to start the PSIC with -Login.

Needs testing on *nix platforms, so still WIP.

PR Checklist

Note: Tick the boxes below that apply to this pull request by putting an x between the square brackets.
Please mark anything not applicable to this PR NA.

  • PR has a meaningful title
  • Summarized changes
  • PR has tests
  • This PR is ready to merge and is not work in progress
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready

@rjmholt rjmholt requested a review from TylerLeonhardt January 2, 2020 23:45
src/session.ts Outdated

private isLoginShell(pwshPath: string): boolean {
try {
cp.execFileSync(pwshPath, ["-Login", "-NoProfile", "-NoLogo", "-Command", "exit 0"]);
Copy link
Member

Choose a reason for hiding this comment

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

What does this throw if it's not the login shell?

Also, did your change to allow PowerShell to be a login shell make it in PS 6.2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What does this throw if it's not the login shell?

The child_process docs say:

If the process times out or has a non-zero exit code, this method will throw an Error that will include the full result of the underlying child_process.spawnSync().

So when the -Login switch is not recognised and PowerShell exits with a non-zero exit code, node throws, we catch and return false.

Also, did your change to allow PowerShell to be a login shell make it in PS 6.2?

No, only in 7 I think. But since you can install PowerShell to any path and configure VSCode to pick that up, we have no way of knowing what version a PS executable is, so are forced to run it to check.

I'll add a comment.

I should also say I haven't tested this, since I've been working on Windows. Why it's still in draft.

Copy link
Member

@TylerLeonhardt TylerLeonhardt Jan 4, 2020

Choose a reason for hiding this comment

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

Sorry I meant that I think -Login existed in 6.2 but it was a no-op so that might be a false positive... Or maybe that was just -l I can't remember.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohhh, I see! We might need @SteveL-MSFT's thoughts there. I think there was indeed a -l in either 6.2 or a 7 preview, although it possibly was short for -LoadProfile

Copy link
Member

Choose a reason for hiding this comment

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

@rjmholt is correct, 6.2 only supported -l as short for -loadprofile making it "compatible" with Unix expecting -l to be accepted. -login will fail on 6.2

Copy link
Member

Choose a reason for hiding this comment

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

This is in 6.2.2 @SteveL-MSFT . This is a weird error output, isn't it?

pwsh -l
Invalid argument '-l', did you mean:

  -nologo
  -noprofile
  -windowstyle
  -file
  -executionpolicy
  -settingsfile
  -help
  -removeworkingdirectorytrailingcharacter

Copy link
Member

Choose a reason for hiding this comment

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

My memory is failing me. Looks like it was added in 7.0 but has been superceded by Rob's change to support -login: PowerShell/PowerShell#9528

@rjmholt
Copy link
Contributor Author

rjmholt commented Jan 9, 2020

Based on this comment, we should default the config setting to true on macOS and false elsewhere

@TylerLeonhardt
Copy link
Member

@rjmholt go ahead and review your own PR, I've made the changes lol

@rjmholt rjmholt marked this pull request as ready for review January 10, 2020 18:43
@rjmholt
Copy link
Contributor Author

rjmholt commented Jan 10, 2020

LGTM!

@TylerLeonhardt TylerLeonhardt merged commit 9f9f6ca into PowerShell:master Jan 10, 2020
@bgelens
Copy link

bgelens commented Jan 16, 2020

@rjmholt Now it's released. Thank you!! It is working as expected 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Login switch not used
4 participants