Script fails with command not found error message

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

When running a script in Bamboo it fails and shows "'\r': command not found" and other syntax errors.

Environment

Bash Script created/edited on Windows OS.

Diagnosis

Looking at the logs of a failed build, the following errors can be seen:

Build log snippets

1 2 3 4 5 6 7 '\r': command not found syntax error near `]] syntax error in conditional expression Illegal characters found in URL

Cause

The issue is caused when the script file has a line ending formatting from Windows which is not recognized by bash causing syntax errors. This can happen if the script file being used was, at some point, edited in a Windows machine or had its encoding changed.

Solution

To resolve this issue you can use Dos2Unix or a similar tool to convert the script file encoding from Windows to Unix encoding. For example:

dos2unix example

1 dos2unix script.sh
Updated on April 24, 2025

Still need help?

The Atlassian Community is here for you.