/bin/sh under Mac OS X is not the same as under linux

December 3rd, 2011 § 0 comments § permalink

I just encountered a rather interesting issue while doing some shell scripting under Mac OS X 10.6 Snow Leopard. While this code perfectly runs:

#!/bin/sh

function foo {
  echo "blabla"
}

foo

It won’t under linux

/path/foo.sh: 3: function: not found
blabla
/path/foo.sh: 5: Syntax error: "}" unexpected

The solution is to change “#!/bin/sh” to “#!/bin/bash”. And then it works under both systems.

Changing iTerm2 tab title

November 30th, 2011 § 0 comments § permalink

Something small but powerful for the shell junkies like me:

echo -ne "\033]0;Blabla\007"

This will change the tab title to “Blabla” and make it easier to find the appropriate window, which sometimes can end up in a hide and seek game.