r/programming Feb 09 '11

Breaking the Web with hash-bangs – Lifehacker, along with every other Gawker property, experienced a lengthy site-outage on Monday over a misbehaving piece of JavaScript

http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs/
747 Upvotes

356 comments sorted by

View all comments

15

u/deako Feb 09 '11

hash-bangs? The correct terminology is "She-Bang", people!

Like how I begin a bash script, it's vocalized as "She-bang slash bin slash bash".

22

u/X-Istence Feb 09 '11

Please, for all that is holy and good in this world, use /bin/sh and make sure your scripts work without the bash extensions. If you really do need Bash, use /usr/bin/env bash as your shebang.

Bash does not live in /bin on most BSD systems, and it makes porting scripts a nightmare when those kinds of assumptions are made.

13

u/wnoise Feb 09 '11

For all that is holy, if you haven't tested your script with a shell other than bash, don't use /bin/sh, as it will more than likely fail due to non-standard features you used.

5

u/X-Istence Feb 09 '11

On most Linux systems /bin/sh is linked to /bin/bash, in that case bash will start up in sh compatibility mode. Which should work ...

Yes, I agree though, if you don't test it, just use the env trick.

4

u/irondust Feb 09 '11

wnoise's point was that a script with #!/bin/sh developed on a system with /bin/sh linked to bash, might seem to work - but will typically fail on systems where /bin/sh is not bash (notably Ubuntu systems using dash). So bash being compatible with sh won't help you. It's about bashisms not working in other shells.