W/hen i run the following code snippet
if [ "foo" = "foo" ];
sfm_write_buffer_test.sh: line 9: syntax error: unexpected end of file
You're on Cygwin, right?
As I said in a comment, when I copy-and-paste your script and run it on my system, it works; the output is
But when I change the line endings from the Unix style
'\n' to the Windows style
'\r\n', I get the same error you got.
With the Windows-style line endings, bash doesn't see the
then keyword; it sees a command named
then\r. It never tries to execute it because it's scanning for the matching
fi for the
if keyword (which it recognized because it's not at the end of the line).
Make sure your shell scripts use Unix-style line endings.