Skip to content

The pwsh CLI should support the -l / --login option for macOS compatibility, e.g. in VSCode #7704

@mklement0

Description

@mklement0

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 --login

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Committee-ReviewedPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.WG-Interactive-Consolethe console experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions