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
To see the problem in action with Visual Studio Code:
- Add
/usr/local/bin/pwsh to /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
pwsh with -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)
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
pwshyour default shell on macOS, certain applications may invokepwshwith-l, which currently breaks the invocation.Specifically, Visual Studio Code does that, so on a macOS system that uses
/usr/bin/pwshas the default shell, the integrated terminal fails to load (unless you happen to have the PowerShell extension installed and happen to open a*.ps1file).It would be sufficient for
pwshto accept-l/--loginand otherwise simply ignore it, as the behavioral implications of this option in the context ofbashdon't apply to PowerShell.Steps to reproduce
To see the problem in action with Visual Studio Code:
/usr/local/bin/pwshto/etc/shellschsh -s /usr/local/bin/pwshcode <file>to open a file for editing, where<file>must not be a PowerShell file.pwshwith-l.Expected behavior
An interactive PowerShell session should start, as if the option hadn't been specified.
Actual behavior
Environment data