3

I have this simple Bash script:

#!/bin/bash java -jar ClosureCompiler/compiler.jar --js ../src/typescript.js --js ../src/ts-compiler.js --js_output_file TSCompiler.js 

I'm getting this error when I try to run the script using build.sh in the MSYS environment under Windows (64-bit!):

./build.sh: ./build.sh: cannot execute binary file 

But the command itself works if I type it directly into the command line window!

3
  • 1
    Whatever the problem is, it's with the script itself and not the command in the script. What text editor did you save the script with, maybe it has lines ending in CR/LF instead of LF?
    – Random832
    CommentedOct 29, 2012 at 19:55
  • @Random832 I have already changed them to LF using Notepad++.
    – ComFreek
    CommentedOct 29, 2012 at 20:06
  • That's a weird error message: build.sh is telling you it can't run build.sh? What's the output of file build.sh?
    – jw013
    CommentedOct 29, 2012 at 20:12

1 Answer 1

2

The file was encoded in UCS-2 Little Endian !
Changing the encoding to UTF-8 without BOM resolved the issue.

2
  • 1
    Msys copes with Windows line endings. Cygwin doesn't. Neither copes with weird Windows formats that aren't ASCII-based, such as UCS-2 or UTF-8 with a U+FEFF prepended (which Windows calls a BOM).CommentedOct 29, 2012 at 22:30
  • @Gilles I've just tried it using Cygwin: it doesn't work - as you said! The problem is that PowerShell adds a CRLF EOL symbol at the end of the file. Here's my question at SO if someone can help: stackoverflow.com/questions/13135808/…
    – ComFreek
    CommentedOct 30, 2012 at 9:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.