You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 10.0.17763.0 Microsoft Windows NT 10.0.17763.0
wsl lsb_release -r
Release: 18.04
wsl cat /proc/version
Linux version 4.4.0-17763-Microsoft ([email protected]) (gcc version 5.4.0 (GCC) ) #1217-Microsoft Mon May 05 16:09:00 PST 2020
Steps to reproduce
Run a command that pipes the output to another linux command inside Powershell
e.g.
wsl echo "test" >> ~/test.txt
ls ~/test.txt
ls (correctly) reads ~ as the Windows home directory. That isn't the problem. The problem is that the >> wrote to the windows directory and not the wsl user's home directory
The only way I could get this to work is by escaping the >> operators so they get interpreted by the WSL *nix appliance like so this writes the file where'd I expect.
wsl echo "test" `>`> ~/text.txt
wsl ls ~/test.txt
I found the issue with absolute paths as well
PS C:\Users\bhatchet> wsl echo "test" >> /home/root/test.txt
out-file : Could not find a part of the path 'C:\home\root\test.txt'.
At line:1 char:1
+ wsl echo "test" >> /home/root/test.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Out-File], DirectoryNotFoundException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
I get that powershell is escaping the >> commands so ~ evaluates to the windows home directory of the user and escaping works, but it gets pretty hairy pretty quickly.
Amend to what @therealkenc said: That ls is an alias of Get-ChildItem, it's the powershell-version (You can verify this with for example ls ~/desktop (verifying via case-insensitivity and desktop-folder existence)
Environment
[Environment]::OSVersion
wsl lsb_release -r
wsl cat /proc/version
Steps to reproduce
Run a command that pipes the output to another linux command inside Powershell
e.g.
ls (correctly) reads ~ as the Windows home directory. That isn't the problem. The problem is that the >> wrote to the windows directory and not the wsl user's home directory
The only way I could get this to work is by escaping the >> operators so they get interpreted by the WSL *nix appliance like so this writes the file where'd I expect.
I found the issue with absolute paths as well
I get that powershell is escaping the >> commands so ~ evaluates to the windows home directory of the user and escaping works, but it gets pretty hairy pretty quickly.
Like, creating a linux user from outside wsl
Expected behavior
Piping / redirecting *nix commands stay relative to *nix inside wsl execute
Actual behavior
Piping / redirecting *nix commands use windows after the redirect inside wsl execute.
The text was updated successfully, but these errors were encountered: