1

Is the Linux "sh" able to run Unicode text script files with BOM (Byte Order Mark) at the beginning?

I really need this and do not want to remove BOM.

Paul
  • 986

1 Answers1

2

Somewhat. Although the kernel will not recognize executable scripts with a #!/bin/... header if they also have an UTF-8 BOM, they should still be recognized by the parent shell itself (the traditional POSIX way), and they can still be run by manually invoking the shell interpreter:

sh myscript.sh

The shell will treat the BOM as part of the first line, so don't bother including the #! header, but instead make sure the script starts with a dummy command to consume it:

: 2>/dev/null

UTF-16 is not supported, whether with BOM or without.

grawity
  • 501,077