[ccache] [PATCH] Use bash for test.sh.

Andrew Stubbs ams at codesourcery.com
Tue Nov 6 02:54:24 MST 2012


On 05/11/12 17:58, Eitan Adler wrote:
>> -#!/bin/sh
>> +#!/bin/bash
>
>
> This line is buggy:
> please http://blog.eitanadler.com/2012/10/binbash-considered-harmful.html
> for why.
>
> I ideally the non-portable bashims get fixed but if not the shebang
> line must be "/usr/bin/env bash" not /bin/bash.

While it is true that "/usr/bin/env bash" is more portable than 
"/bin/bash", I also don't like it as much.

If I run a "#!/bin/bash" script without bash installed I get:

   /bin/bash: bad interpreter: No such file or directory

If I try the same with "#!/usr/bin/env bash" I get:

   /bin/env: bad interpreter: No such file or directory

which is demonstrably untrue and far less helpful.

In the former case any mildly experienced Unix user will just sigh and 
run the script under bash manually. In the later case you have to be 
very experienced not to spend ages thinking you must be crazy or have 
found a kernel bug, or something.

Now, if the script were deeply embedded in some other tool where the 
user would not be able to intervene then I would consider the env trick, 
but even then I would probably use "#!/bin/sh" and have the script 
locate bash and re-exec itself.

It is, of course, the official Ccache maintainer's call which style is 
preferred, or even whether it's better to find and stamp out the errant 
bashism in the script, but my vote is for the simple /bin/bash option.

Andrew


More information about the ccache mailing list