Errors running bash script from pandoc filters repo in WSL

I’m trying to run runtests.sh from this repo on my local machine using WSL. First I installed WSL using wsl --install Ubuntu. Then I navigated to my local clone and ran sh runtests.sh. I got the following error:

: not found: 4:

: not found: 7:

runtests.sh: 8: Syntax error: word unexpected (expecting "do")

I’m not too familiar with bash scripts, and I’m pretty sure this one should work, since it’s part of a reasonably well maintained repo. There has got to be something wrong with how I’m calling the script.

What am I doing wrong here?

>Solution :

Are you attempting to run a shell script with CRLF line endings?

Use file runtests.sh to confirm.

git will checkout files using CRLF line endings on windows if core.autocrlf is true.

Use git config core.autocrlf from the cloning machine (not necessarily the WSL2) to confirm.

To disable this behavior and reset your working directory:

git config core.autocrlf false
git checkout -- .

Leave a Reply