-
Notifications
You must be signed in to change notification settings - Fork 133
draft to enable pwsh to be used as login shell #171
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| --- | ||
| RFC: RFCnnnn | ||
| Author: Steve Lee | ||
| Status: Draft | ||
| SupercededBy: N/A | ||
| Version: 1.0 | ||
| Area: Console | ||
| Comments Due: June 6, 2019 | ||
| Plan to implement: Yes | ||
| --- | ||
|
|
||
| # Enable PowerShell as Login Shell on POSIX-based systems | ||
|
|
||
| POSIX shells on Unix-based systems use a `-l` switch to start the shell as a login shell. | ||
| This means the shell is not being started from an existing configured environment and | ||
| needs to execute `/etc/profile` to populate environment variables along with other | ||
| environment changes. | ||
|
|
||
| ## Motivation | ||
|
|
||
| As a PowerShell user, | ||
| I can use PowerShell as my login shell on Unix-based systems, | ||
| so that I can use PowerShell everywhere. | ||
|
|
||
| ## Specification | ||
|
|
||
| Many existing tools expect `-l` to be accepted by a shell and to act as a login | ||
| shell. | ||
|
|
||
| `-l` (expanded form is `-LoadProfile`) will explicitly have pwsh load the PowerShell | ||
| profile. | ||
| This is effectively a no-op as if this switch is not specified, pwsh will load | ||
| the PowerShell profile and only doesn't load it if `-noprofile` is specified. | ||
|
|
||
| This will allow tools that expect `-l` to be accepted to work. | ||
| There is no additional work to process `/etc/profile` when `-l` is used. | ||
|
|
||
| For cases where you do need `/etc/profile` to be processed, | ||
| such as using pwsh as your default shell, | ||
| the proposal is to include a Bourne shell script that can be specified as the | ||
| shell: | ||
|
|
||
| ```sh | ||
| #!/bin/sh -l | ||
| exec /usr/local/bin/pwsh "$@" | ||
| ``` | ||
|
|
||
| This script will be called `pwsh-login` and should be used whenever you require | ||
| a specific login shell. | ||
|
|
||
| ## Alternate Proposals and Considerations | ||
|
|
||
| ### Process /etc/profile using sh and copy the env vars | ||
|
|
||
| This proposal would be that if `-l` is specified, pwsh would run `/bin/sh -l -c export` | ||
| which would create a new shell process that does all the processing needed for | ||
| a login shell and export the environment variables that would be exported. | ||
| Additional code is needed to take those environment variables and copy them to | ||
| the parent pwsh process. | ||
|
|
||
| The downsides to this approach is additional code to maintain, | ||
| but more importantly not getting a complete login shell environment as things | ||
| like ulimit and umask would not be inherited into pwsh. | ||
|
|
||
| ### pwsh to start `/bin/sh -l -c "exec pwsh"` | ||
|
|
||
| This proposal would have pwsh when given the `-l` switch to start Bourne shell | ||
| as a login shell and start pwsh within that process. | ||
|
|
||
| This would result in a complete login shell environment, however, would | ||
| incur the performance penalty of starting pwsh twice. | ||
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.
Uh oh!
There was an error while loading. Please reload this page.