Unexpected token Error During Ant Build
Today I was facing the Strange Error, Which I have not Faced earlier.
Error Log:
$ ./cant create-ear
./cant: line 2: $'\r': command not found
./cant: line 4: $'\r': command not found
create-ear
./cant: line 32: syntax error near unexpected token `elif'
'/cant: line 32: `elif [ "$system" = "Linux" ];then
Later Investigating it Found the Issue with the File System. Hence Googled it and Found the Solution. The Solution is First Identify which Machine are you using, ie Linux or Windows. Then Procced to the Solution
Cause:
In My case, I was using the Linux Machine and trying to execute the File Saved in Windows.
Solution:
To Fix this Open the File in Notepad ++ and Navigate to EDIT>EOL Conversion
Select Unix(LF) Conversion If you need to execute it in the Linux Environment.
Select Windows (CR LF) In case you need to execute in Windows Environment.
Select Macintosh (CR) In Case of Mac.
This Solution is not Specific to ant alone, can be used for other files as well.
Happy Learning !!!