-
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
Conversation
|
@mklement0 Please look the RFC. |
|
In short:
|
|
@SteveL-MSFT (I've deleted my previous comment after digging deeper): I've updated PowerShell/PowerShell#975 (comment) to show that we indeed need to use the call- However, what I now realize is a must is that PowerShell recognize a
|
|
@mklement0 as always, I appreciate you digging into these details. I don't think we should put in a workaround for |
|
Thanks, @SteveL-MSFT; I've asked for clarification in https://github.com/dotnet/coreclr/issues/20562 whether the fix will give us what we need; it makes sense to wait for a proper fix, but just to be clear: without it, whatever functionality this RFC implements will lie dormant in (at least) two important scenarios: creating a new shell interactively on macOS, and using |
|
Just a clarification up front: The shell-related part of POSIX is a specification that compliant shells must adhere to; POSIX-like shell implementations, such as Bash, comply to varying degrees. Profile files, from what I can tell, are actually not prescribed by POSIX, but de facto POSIX-like shells (with the exception of Reading Note that these files shouldn't contain Bash code, only code that complies with the POSIX shell specification, which is a subset of Bash. Limiting the code to POSIX-only language features ensure that all POSIX-compatible shells can read it. The only POSIX-mandated behavior with respect to startup files is a script specified via the optional |
|
Re 3.: Agreed. Re 2: I get that that the proposed approach is unsatisfying: it is clunky, slow, and only half solves the problem, given that it covers only environment variables, whereas It is desirable, however, to fully honor If we provided a separate, PowerShell-specific configuration, we'd be asking users to duplicate these settings solely to accommodate PowerShell. At least Ubuntu seems to be moving away from relying on On such a system that doesn't rely on On Ubuntu, for user-created PowerShell sessions, PowerShell needn't process On macOS, most system configuration is managed via |
|
Here's another approach to consider:
While this is obviously slow,
Note that on Linux the performance penalty would typically only be paid via On macOS, however, the penalty would be paid whenever the user creates a new session by opening a new tab or window in a terminal emulator. |
|
@mklement0 the concern I have with your proposed approach is that pwsh would incur the cost of starting twice which IS slow. Simply starting |
|
Yes, Given the relative rarity of login shells - at least on Linux - when given the choice between a faster half-workaround and a slower, but complete workaround, my vote is for the latter. |
|
@mklement0 to give you a sense of the cost of startup for a managed assembly, on my macBook Pro: PS> (Measure-Command { pwsh -? }).TotalMilliseconds
235.5875
PS> (Measure-Command { pwsh -c exit }).TotalMilliseconds
1097.442In the first case, all the processing is within pwsh and it doesn't create a PowerShell runspace, simply outputs help. The second case, it creates a runspace and exits. Simply shelling out to sh to process profile is really fast: PS> (Measure-Command { /bin/sh -c /etc/profile }).TotalMilliseconds
14.1075I'm currently just looking for a "good enough" solution so people can start using pwsh as their default shell. |
|
That's illuminating, @SteveL-MSFT, though note that your numbers include processing of PowerShell profile files in the case of the However, that's still significant, and what I'm proposing indeed does not require creating a PowerShell runspace on the initial invocation, so the performance impact wouldn't be that bad, right? |
|
As for:
My sense is that |
|
I very wonder that we discuss low level implementation details in RFC repository instead of and before defining general conceptions and features of their existence on various platforms. |
|
@mklement0 yes, I forgot about my $profile which inflated the times by quite a bit. Perhaps if I can find some free time I can prototype both approaches and see what the perf difference is. |
|
I'd want to get answers from the RFC
Also I'd start with defining config files (and GPO for enterprises) for every shell type:
In this configs we could have options:
Such an approach will give a good understanding of the behavior and will improve adaptation to any (Unix) distributives. |
|
Haven't read the thread yet, but I thought it was worth noting here that we should ignore |
|
|
|
@SteveL-MSFT: @joeyaiello: With the reinvoke-via- |
|
My sense is that logon shells are a legacy construct, stemming from a time when the shell was the only UI. Therefore:
|
|
@joeyaiello, @JamesWTruher and I discussed this today. I was a bit dissatisfied with the idea of executing the profile file with My first instinct was that maybe starting @JamesWTruher suggested that this is exactly what @joeyaiello then suggested that a simple and effective solution is a wrapper script (perhaps #/bin/sh -l
exec pwsh "$@"Discussing this we were curious about how other
|
We're talking about using using This means that a single executable -
So it sounds like a wrapper script with a different executable name is not an option - or am I missing something? That is, unless you want to:
Pragmatically speaking, I don't think we need too concerned about the user-level By contrast, it is the system-wide, shell-transcendent importance of |
It seems a main feature of login shell is to reset process "config" and create it from scratch (including env). |
Note: I am not an expert in these things, but hopefully the essence of the following is correct: No. My understanding is that login shells are not about resetting (on demand), but about one-time initializations at the time a user OS session starts (when the user logs on to a machine), and that initialization sets the environment variables and process attributes for all subsequently invoked processes, including other shell instances. This dates back to a time of the Bourne shell, the predecessor of the POSIX shell specification and modern POSIX-like shells, when a character-mode shell was the shell for a user's OS session (not a GUI shell as is customary today). At least Ubuntu still seems to be doing that behind the scenes, via a hidden Regrettably, macOS doesn't; on macOS - for reasons unknown to me - GUI apps and POSIX-compatible shells are designed to see different environments, with shells expected to make additional modifications to the environment beyond the shared mechanism (launchd), most notably the initial The other major scenario in which login shells matter is in remoting: when you use Now, if the SSH daemon on the target machine had (indirectly) also processed However, my sense is that Ubuntu is trying to move way from The above is distinct from wanting to start a shell with a pristine environment on demand; I know of |
Also we can type Ubuntu has its way. MacOs has its way too. And so on. |
No, I meant this issue only. |
No, it's not a clean session. Any environment variables and process attribute that aren't set in But the main point is that that providing a "clean" session is not the purpose of a login shell. |
What is definition of login shell? In common what is interactive vs noninteractive vs login? |
|
I've tried to explain the purpose of login shells in previous comments. Their purpose is entirely unrelated to interactive vs. noninteractive - in Bash terms, that distinction matters only with respect to the "rc file",
PowerShell cannot and therefore shouldn't even try to fulfill that role: Neither on Linux (at least based on my Ubuntu experience) nor on macOS does it get a chance to provide system-wide initializations when a user's OS session starts:
To put it differently: Even making PowerShell a user's default shell does not enable it to perform system-wide initializations. |
|
Completely rewrote the RFC based on feedback and @PowerShell/powershell-committee discussion. Please review the current proposal. |
|
Closing this PR and will submit update as new one as the current comments are outdated. |
|
New PR #186 |
No description provided.