Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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!

share|improve this question
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 Oct 29 '12 at 19:55
    
@Random832 I have already changed them to LF using Notepad++. –  ComFreek Oct 29 '12 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 Oct 29 '12 at 20:12
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
    
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). –  Gilles Oct 29 '12 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 Oct 30 '12 at 9:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.