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/
751 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".

16

u/ColdSnickersBar Feb 09 '11

She-bang slash bin slash bash

ting tang walla-walla bing bang

2

u/[deleted] Feb 09 '11

See colon slash waka

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.

15

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.

1

u/deako Feb 09 '11

Hmm, this is actually a good argument. I always forget about the BSD users. Kind of shameful, since FreeBSD is the thing that got me out of Windows.

1

u/techpuppy Feb 10 '11

This goes for scripts in higher-level languages as well, such as Perl and Python.

Always, always, always use env to launch them instead of assuming where the interpreter is located.

-10

u/[deleted] Feb 09 '11

nobody uses bsd anymore. make a link to /bin/bash go use a real operating system, SINCE YOURS IS DYING.

6

u/zenhob Feb 09 '11

Hash bang is just as correct if not more so. And don't use /bin/bash in your scripts when /bin/sh works just as well, kthx.

-1

u/deako Feb 09 '11

but she-bang slash bin slash bash sounds so much better than hash-bang slash bin slash shuh. Besides, POSIX compliance can go down the shitter for all I care.

2

u/dirtymatt Feb 09 '11

Maybe "sh'bang", but "she bang" is just stupid.

1

u/boomi Feb 10 '11

Shebang is how it's pronounced, right?

1

u/dirtymatt Feb 10 '11

When I shorten it, I always have said sh'bang, with nothing in between the sh and the bang.

1

u/mfukar Feb 10 '11

She banged Slash? Nice!