Skip to content

Piping to less doesn't work with WSL2 distro #29

@Praful

Description

@Praful

Describe the bug
I have followed the instructions to map various Linux command, including less. If I try to pipe output via less, the command hangs at the colon prompt until I hit CTRL-C. This happens on a distro running as WSL v2. Version 1 distros are fine.

To Reproduce
Steps to reproduce the behavior:

  1. Install WslInterop.
  2. Add following line to PS profile:
Import-WslCommand "apt", "awk", "grep", "head", "less", "sed", "seq", "tail", "dos2unix", "du", "df", "wget", "gzip", "cat", "free", "top", "uname", "wc"
  1. Install Ubuntu from Microsoft Store.
  2. Set this to the default:
wsl -s Ubuntu
  1. Set to WSL 2:
wsl --set-version Ubuntu 2
  1. In new PowerShell (using Windows Terminal), type:
cd <a folder with more than a page of files>
ls | less

The command hangs at :. You can't, for example, press f or b.

Expected behavior
Piping output to less should allow you to page up/down, search, etc.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Windows 10 20H2
  • PowerShell v7.1.2

Additional context
Changing the distribution to WSL 1 fixes the issue:

wsl --set-version Ubuntu 1

In a new Terminal session, the following now works as expected:

ls | less

Thank you for providing this incredibly useful module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions