bash shell script errors – syntax error near unexpected token `$’do\r”

How To

Problem Statement-> syntax error near unexpected token `$’do\r” error while running bash script.

using visual studio to write code on windows machine and the bash script is running on Linux github runner vm inside Terraform Local-exec command.

Root Cause -> Since i was using windows machine and visual studio to write code and the default setting was set to CRLF and the code was running on Linux machine which needs LF

Solution ->

1> Click on CRLF at the bottom of visual studio code windows

bash shell script errors - syntax error near unexpected token `$'do\r''

2> Select LF as shown below:

bash shell script errors - syntax error near unexpected token `$'do\r''


(Visited 144 times, 1 visits today)