bostrot / wsl2-distro-manager

A GUI to quickly manage your WSL2 instances
https://apps.microsoft.com/store/detail/wsl-manager/9NWS9K95NMJB
Other
1.79k stars 108 forks source link

[BUG] Snippets Editor doesn't like copy + paste - CLRF added when code is run on the WSL instance #237

Closed SpoddyCoder closed 4 months ago

SpoddyCoder commented 5 months ago

Is there an existing issue for this?

Current Behavior

Copy / pasting into the snippets editor, results in windows line endings being added to the bash commands - giving unexpected results.

Manually typing the same code into the snippets editor works as expected.

Expected Behavior

Given we are working on Windows hosts and running code on Linux instances - CLRF should be removed to avoid potential issues.

Steps To Reproduce

  1. Manaully type the following into the Snippets editor, & run it...
touch /tmp/myfile
echo "test1" >> /tmp/myfile
echo "test2" >> /tmp/myfile

myfile is created as expected....

$ cat /tmp/myfile
test1
test2

$ cat -vt /tmp/wdmcmds
#!/bin/bash
touch /tmp/myfile
echo "test1" >> /tmp/myfile
echo "test2" >> /tmp/myfile
read -n1 -r -p "

Done running the action. Press any key to exit..." key
  1. Copy + paste the same code into the Snippet editor, run it and the following results....
$ ll /tmp/
-rw-r--r--  1 me me   18 Mar 25 20:48  myfile
-rw-r--r--  1 me me    6 Mar 25 20:48 'myfile'$'\r'
-rw-r--r--  1 me me  161 Mar 25 20:48  wdmcmds

$ cat /tmp/myfile
test2

$ cat -vt /tmp/wdmcmds
#!/bin/bash
touch /tmp/myfile^M
echo "test1" >> /tmp/myfile^M
echo "test2" >> /tmp/myfile
read -n1 -r -p "

Done running the action. Press any key to exit..." key

Environment

- Windows Version: Windows 11 23H2 (OS Build 22631.3296)
- WSL Distro Manager Version: 1.8.11
- WSL Version: 2.1.5.0
- Source: Github releases

Anything else?

This happens even when you copy + paste from VSCode that is running from the Linux instance, set to LF endings....

wsl2-distro-manager-issue

github-actions[bot] commented 5 months ago

Hello there! As you are a first time Issuer please read our Code of Conduct. Please also check whether your issue description is reasonable and complete. If you are having an issue always include the version you are using (WSL, this app, Windows) as well as a way to reproduce it.