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

2012-11-06 Thread Eitan Adler
On 6 November 2012 04:54, Andrew Stubbs  wrote:
>
> 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

Perhaps you should get a better version of env?
I get:

[10026 eitan@radar ~ ]%./hello
env: asdf: No such file or directory
[10027 eitan@radar ~ !127!]%cat hello
#!/usr/bin/env asdf

> 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.

In the former case the package maintainers must fix the portability
bug the upstream author has introduced.
In the latter case they just have to add a dependency.

> 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.

The followup to this discussion indicates that /bin/sh seems to be
sufficient (I need to check this myself when I get a chance).
checkbashims sees nothing wrong.


-- 
Eitan Adler
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


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

2012-11-06 Thread Andrew Stubbs

On 06/11/12 10:05, g@free.fr wrote:

On my debian stable machine (x86 32 bits), I set sh as a symlink to dash and 
changed my script to emit SHELL='/bin/dash'
test is ok with 3.1.8 (ccache is statically linked to glibc in my 
configuration).

I looked with checkbashims on test.sh git version and no warning is emitted.


Perhaps the problem was introduced since 3.1.8 then.

I can't say for sure because it was the first test run I did after 
upgrading to Ubuntu 12.10 that failed. I presumed that the default 
/bin/sh had changed, but it could equally be that the test.sh has 
acquired a bashism at the same time.


As far as I'm concerned, it's perfectly fine if the script only runs in 
bash. The shell is fairly ubiquitous, and test.sh is certainly not 
written in the paranoid style of configure scripts.


Andrew
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


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

2012-11-06 Thread g . esp


- Mail original -
> De: "Andrew Stubbs" 
> À: "g esp" 
> Cc: ccache@lists.samba.org
> Envoyé: Mardi 6 Novembre 2012 10:55:23
> Objet: Re: [ccache] [PATCH] Use bash for test.sh.
> 
> On 05/11/12 22:35, g@free.fr wrote:
> > ccache-3.1.8 'make check' work with dash, no?
> 
> There's no problem with configure or make, only with test.sh.
> 
> Andrew
> 
> 
'make check' target run test.sh

On my debian stable machine (x86 32 bits), I set sh as a symlink to dash and 
changed my script to emit SHELL='/bin/dash'
test is ok with 3.1.8 (ccache is statically linked to glibc in my 
configuration).

I looked with checkbashims on test.sh git version and no warning is emitted.

Gilles
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


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

2012-11-06 Thread Andrew Stubbs

On 05/11/12 22:35, g@free.fr wrote:

ccache-3.1.8 'make check' work with dash, no?


There's no problem with configure or make, only with test.sh.

Andrew

___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


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

2012-11-06 Thread Andrew Stubbs

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
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache