Skip to content

Unexpected backslashes when remoting from Win to Nix #3923

@PowerCoder

Description

@PowerCoder

A minor cosmetic issue described in VSCode's Repo.

Steps to reproduce & actual behavior

If I start PwSH on my Windows-box:

PS C:\Windows\System32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Then use remoting to my Linux box:

PS C:\Windows\System32> Enter-PSSession -HostName 'linuxbox.localdomain' -UserName 'root'
root@linuxbox.localdomain's password:
[root@linuxbox.localdomain]: PS /root> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Linux 5.4.28-1-lts PowerShell/PowerShell#1 SMP Wed, 25 Mar 2020 13:04:22 +0000
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

And then use TAB-completion on file-paths, it will append backslashes instead of forward slashes.
In this case, I typed /tm followed by TAB.

[root@linuxbox.localdomain]: PS /root> Set-Location -Path '/tmp\'

Powershell can, however deal with them, as I can keep typing and the next TAB will auto-correct the backslash to a forward slash.
In this case, I typed /tmp\scrip followed by TAB.

[root@linuxbox.localdomain]: PS /tmp> Set-Location -Path '/tmp/scriptroot\'

Pressing Enter on the above command also works fine with the backslash.

[root@linuxbox.localdomain]: PS /tmp/scriptroot>_

If I (as accurately as is possible) reproduce the steps involved in a Enter-PSSession over SSH by:

  • Starting PwSh on Windows
  • From there using the Windows OpenSSH client native to Win10 to connect to the Linux box
  • And finish by starting pwsh manually from the default Linux shell
    it works just fine:
PS C:\Windows\System32> ssh root@linuxbox.localdomain
root@linuxbox.localdomain's password:
Last login: Thu Apr  2 23:34:34 2020 from 192.168.xxx.xxx
root@linuxbox ~ # pwsh
PowerShell 7.0.0
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/powershell
Type 'help' to get help.

PS /root> Set-Location -Path '/tmp/'
PS /tmp> Set-Location -Path '/tmp/scriptroot/'
PS /tmp/scriptroot>                           

In other news, I notice the previous PSRemoting session isn't registered as a login session.

PS /tmp/scriptroot> last
root     pts/0        192.168.xxx.xxx   Fri Apr  3 20:02   still logged in
root     pts/0        192.168.xxx.xxx   Thu Apr  2 23:34 - 23:36  (00:01)

Linux security admins everywhere are blocking PwSh-over-SSH right now.

Expected behavior

Do you want me to write it out? Expected behavior is when TAB auto-complete appends forward slashes instead of backslashes. Which happens when running pwsh from the linux console, as well as when I connect using SSH into the default shell first, before starting pwsh from said shell.

My guess is it has something to do with the fact that the parent-session is Windows. But since Linux-native commands like ls (and as you can see last) work, it would mean that IsLinux should be $True. I'll leave it to the experts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIt either shouldn't be doing this or needs an investigation.Resolution-Fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions