-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Related: #3743
On macOS, unlike on Linux, all (user-)default shell instances are started as login shells.
There are two mechanisms for invoking a shell as a login shell: (a) setting its argv[0] to contain - as the 1st character (that's what Terminal.app does) or (b) passing the -l (or --login) option to the shell executable.
If you make pwsh your default shell on macOS, certain applications may invoke pwsh with -l, which currently breaks the invocation.
Specifically, Visual Studio Code does that, so on a macOS system that uses /usr/bin/pwsh as the default shell, the integrated terminal fails to load (unless you happen to have the PowerShell extension installed and happen to open a *.ps1 file).
It would be sufficient for pwsh to accept -l / --login and otherwise simply ignore it, as the behavioral implications of this option in the context of bash don't apply to PowerShell.
Steps to reproduce
pwsh -l
pwsh --loginTo see the problem in action with Visual Studio Code:
- Add
/usr/local/bin/pwshto/etc/shells - Make PowerShell your default shell with
chsh -s /usr/local/bin/pwsh - Open a new terminal and close existing Visual Studio Code windows.
- Use
code <file>to open a file for editing, where<file>must not be a PowerShell file. - Try to access the integrated terminal, which crashes due to invoking
pwshwith-l.
Expected behavior
An interactive PowerShell session should start, as if the option hadn't been specified.
Actual behavior
Invalid argument '-l', did you mean:
...
The argument '--login' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
...
Environment data
PowerShell Core v6.1.0-rc.1 on macOS 10.13.6
PowerShell Core v6.1.0-rc.1 on Ubuntu 16.04.4 LTS
PowerShell Core v6.1.0-rc.1 on Microsoft Windows 10 Pro (64-bit; Version 1803, OS Build: 17134.165)
Windows PowerShell v5.1.17134.165 on Microsoft Windows 10 Pro (64-bit; Version 1803, OS Build: 17134.165)