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

2012-11-12 Thread Eitan Adler
On 12 November 2012 13:52, Paul Smith  wrote:
> On Mon, 2012-11-12 at 13:11 -0500, Eitan Adler wrote:
>> #!/bin/sh  which is mandated to exist by POSIX
>
> Actually, unless there's been a change, POSIX doesn't mandate that the
> POSIX shell appear as /bin/sh.

Okay. Taking a deeper look here, I'm wrong. That said, #!/bin/sh is
certainly still more portable than #!/bin/bash and the latter is still
a portability bug.

> Unfortunately, this means that systems are free to provide definitively
> non-POSIX /bin/sh and still be allowed to paint themselves with the
> veneer of compliance (yes I'm looking at you Solaris!!), since there is
> a POSIX shell somewhere (else) on the system.

Yes, this can happen. :(




-- 
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-12 Thread Paul Smith
On Mon, 2012-11-12 at 13:11 -0500, Eitan Adler wrote:
> #!/bin/sh  which is mandated to exist by POSIX

Actually, unless there's been a change, POSIX doesn't mandate that the
POSIX shell appear as /bin/sh.

Unfortunately, this means that systems are free to provide definitively
non-POSIX /bin/sh and still be allowed to paint themselves with the
veneer of compliance (yes I'm looking at you Solaris!!), since there is
a POSIX shell somewhere (else) on the system.

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


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

2012-11-12 Thread Eitan Adler
On 12 November 2012 13:11, Eitan Adler  wrote:
> On 12 November 2012 13:04, Mike Frysinger  wrote:
>> yes, when people tell you forcing asinine behavior is wrong, you label them
>> trolls.  i guess that's how you "win" arguments.
>
> Claiming that systems without /bin/bash are "crap" shows a level of
> naivete that only someone new to the open source world has. It was a
> choice between actual
> incompetence (unlikely) or pretend incompetence (a troll).
>
> On to the substance instead of my mistaken ad hominem :
>
> 1) Even on systems with a binary called /bin/bash using "#!/bash/bash" is 
> wrong
> 2) Many systems don't ship with bash at all for licensing, technical,
> or preference reasons
> 3) Most operating systems that ship bash don't ship it in /bin
>
> The only correct behaviors are using
>
> #!/usr/bin/env bash to find the bash binary
> or
> #!/bin/sh  which is mandated to exist by POSIX

actually one more valid behavior:

#!/bin/sh
[ -z "$BASH" ] && bash $0

though this is far less common and I'm not sure if it has any
positives or negatives versus the 'env' approach.

-- 
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-12 Thread Eitan Adler
On 12 November 2012 13:04, Mike Frysinger  wrote:
> yes, when people tell you forcing asinine behavior is wrong, you label them
> trolls.  i guess that's how you "win" arguments.

Claiming that systems without /bin/bash are "crap" shows a level of
naivete that only someone new to the open source world has. It was a
choice between actual
incompetence (unlikely) or pretend incompetence (a troll).

On to the substance instead of my mistaken ad hominem :

1) Even on systems with a binary called /bin/bash using "#!/bash/bash" is wrong
2) Many systems don't ship with bash at all for licensing, technical,
or preference reasons
3) Most operating systems that ship bash don't ship it in /bin

The only correct behaviors are using

#!/usr/bin/env bash to find the bash binary
or
#!/bin/sh  which is mandated to exist by POSIX


What behavior does 'env' provide that you think isn't good?


-- 
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-12 Thread Mike Frysinger
On Monday 12 November 2012 06:03:37 Andrew Stubbs wrote:
> Running "sh -x test.sh" shows that the gcc command producing the error:
> 
> + CCACHE_DISABLE=1 gcc -c test1.c -o reference_test1.o -O -O
> gcc: error trying to exec 'cc1': execvp: No such file or directory
> 
> I don't understand what's wrong with that command. gcc isn't supposed to
> rely on the PATH to find cc1, but presumably it's something environmental.

it relies on argv[0] to locate its internal tools.  if you change that command 
to `env CCACHE_DISABLE=1 ...`, does it work better ?
-mike


signature.asc
Description: This is a digitally signed message part.
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


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

2012-11-12 Thread Mike Frysinger
On Saturday 10 November 2012 05:08:40 Joel Rosdahl wrote:
> On 10 November 2012 06:45, Mike Frysinger  wrote:
> > i see old style portable code in there that could easily be modernized to
> > recent POSIX
> 
> Please don't strive to do that. Solaris's /bin/sh isn't POSIX.

autoconf searches well known paths to locate an up-to-date shell.  my limited 
understanding is that Solaris stores modern tools somewhere in /usr/.  would 
you be amendable to having the script re-exec itself via those so we can 
update things ?
-mike


signature.asc
Description: This is a digitally signed message part.
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


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

2012-11-12 Thread Mike Frysinger
On Sunday 11 November 2012 06:31:14 Eitan Adler wrote:
> On 11 November 2012 00:46, Mike Frysinger  wrote:
> > On Saturday 10 November 2012 00:41:52 Eitan Adler wrote:
> >> On 10 November 2012 00:41, Mike Frysinger wrote:
> >> > if the script is written in bash and is intended to be, then
> >> > /bin/bash is the correct answer.
> >> 
> >> Absolutely false. /usr/local/bin or /opt/bin might be the correct
> >> location.
> > 
> > if you have a crap system where bash isn't installed with /bin/bash, then
> > you already have a ton of problems with existing software.  forcing
> > stupid behavior on everyone to cater to broken systems is wrong.
> 
> http://www.technollama.co.uk/wordpress/wp-content/uploads/2011/05/obvious-t
> roll.jpg

yes, when people tell you forcing asinine behavior is wrong, you label them 
trolls.  i guess that's how you "win" arguments.
-mike


signature.asc
Description: This is a digitally signed message part.
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


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

2012-11-12 Thread Eitan Adler
On 12 November 2012 13:00, Eitan Adler  wrote:
> On 12 November 2012 06:03, Andrew Stubbs  wrote:
>> Running "sh -x test.sh" shows that the gcc command producing the error:
>>
>> + CCACHE_DISABLE=1 gcc -c test1.c -o reference_test1.o -O -O
>> gcc: error trying to exec 'cc1': execvp: No such file or directory
>>
>> I don't understand what's wrong with that command. gcc isn't supposed to
>> rely on the PATH to find cc1, but presumably it's something environmental.
>
> Can you get a ktrace (or strace) of what gcc is doing with and without CCACHE 
> ?

Also, does gcc exhibit problems on other test programs outside of test.sh ?


-- 
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-12 Thread Eitan Adler
On 12 November 2012 06:03, Andrew Stubbs  wrote:
> Running "sh -x test.sh" shows that the gcc command producing the error:
>
> + CCACHE_DISABLE=1 gcc -c test1.c -o reference_test1.o -O -O
> gcc: error trying to exec 'cc1': execvp: No such file or directory
>
> I don't understand what's wrong with that command. gcc isn't supposed to
> rely on the PATH to find cc1, but presumably it's something environmental.

Can you get a ktrace (or strace) of what gcc is doing with and without CCACHE ?




-- 
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-12 Thread Andrew Stubbs

On 11/11/12 11:31, Eitan Adler wrote:

Mike,

http://www.technollama.co.uk/wordpress/wp-content/uploads/2011/05/obvious-troll.jpg


Insulting respected members of the Linux community will get you nowhere. 
I realise that some might call you the same, and BSD also, so you should 
know better.



Andrew,

I don't think we ever solved the problem you saw? What error did you
get with what shell?


It does seem that just using bash is not sufficient to solve this 
problem. Joel has declared that it must work on Solaris /bin/sh, so work 
there it must. Not that I have any means to test that.


Anyway, here's the transcript showing the problem:

/tmp/ccache$ ./test.sh
starting testsuite base
starting testsuite link
gcc: error trying to exec 'cc1': execvp: No such file or directory
gcc: error trying to exec 'cc1': execvp: No such file or directory
SUITE: "link", TEST: "CCACHE_CPP2" - Files differ: reference_test1.o != 
test1.o

cache directory /tmp/ccache/testdir.18802/.ccache
primary config  /tmp/ccache/testdir.18802/ccache.conf
secondary config  (readonly)
cache hit (direct) 0
cache hit (preprocessed)   4
cache miss 3
called for link2
called for preprocessing   1
multiple source files  1
compiler produced stdout   1
couldn't find the compiler 1
bad compiler arguments 1
unsupported source language1
unsupported compiler option1
output to a non-regular file   1
no input file  1
files in cache 3
cache size  12.3 kB
max cache size   5.0 GB
TEST FAILED
Test data and log file have been left in testdir.18802

I've deliberately moved the sources to /tmp to side-step any possible 
problems caused by calling test.sh from another directory, but it made 
no visible difference.


And now again with bash:

/tmp/ccache$ bash ./test.sh
starting testsuite base
starting testsuite link
starting testsuite hardlink
starting testsuite cpp2
starting testsuite nlevels4
starting testsuite nlevels1
starting testsuite basedir
starting testsuite direct
starting testsuite compression
starting testsuite readonly
starting testsuite extrafiles
starting testsuite cleanup
starting testsuite pch
starting testsuite upgrade
starting testsuite prefix
test done - OK

checkbashisms does indeed return nothing.

Running "sh -x test.sh" shows that the gcc command producing the error:

+ CCACHE_DISABLE=1 gcc -c test1.c -o reference_test1.o -O -O
gcc: error trying to exec 'cc1': execvp: No such file or directory

I don't understand what's wrong with that command. gcc isn't supposed to 
rely on the PATH to find cc1, but presumably it's something environmental.


I'm pretty sure I did not see this problem in the default shell provided 
by Ubuntu 12.04, so it's either a dash bug, or some kind of subtle 
incompatibility.


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-11 Thread Eitan Adler
On 11 November 2012 00:46, Mike Frysinger  wrote:
> On Saturday 10 November 2012 00:41:52 Eitan Adler wrote:
>> On 10 November 2012 00:41, Mike Frysinger wrote:
>> > if the script is written in bash and is intended to be, then
>> > /bin/bash is the correct answer.
>>
>> Absolutely false. /usr/local/bin or /opt/bin might be the correct location.
>
> if you have a crap system where bash isn't installed with /bin/bash, then you
> already have a ton of problems with existing software.  forcing stupid
> behavior on everyone to cater to broken systems is wrong.
> -mike

Mike,

http://www.technollama.co.uk/wordpress/wp-content/uploads/2011/05/obvious-troll.jpg

Andrew,

I don't think we ever solved the problem you saw? What error did you
get with what shell?

Joel,

Thanks for this awesome, portable, piece of software. :)






-- 
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-10 Thread Mike Frysinger
On Saturday 10 November 2012 00:41:52 Eitan Adler wrote:
> On 10 November 2012 00:41, Mike Frysinger wrote:
> > if the script is written in bash and is intended to be, then
> > /bin/bash is the correct answer.
> 
> Absolutely false. /usr/local/bin or /opt/bin might be the correct location.

if you have a crap system where bash isn't installed with /bin/bash, then you 
already have a ton of problems with existing software.  forcing stupid 
behavior on everyone to cater to broken systems is wrong.
-mike


signature.asc
Description: This is a digitally signed message part.
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


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

2012-11-10 Thread Joel Rosdahl
On 10 November 2012 06:45, Mike Frysinger  wrote:
> i see old style portable code in there that could easily be modernized to
> recent POSIX

Please don't strive to do that. Solaris's /bin/sh isn't POSIX.

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


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

2012-11-09 Thread Mike Frysinger
On Monday 05 November 2012 12:55:10 Andrew Stubbs wrote:
> The test script fails with shells other than bash. At least dash
> doesn't work.

could you post the exact errors you see ?  i see old style portable code in 
there that could easily be modernized to recent POSIX and plenty of quoting 
issues, but i don't see anything off hand that wouldn't work in a POSIX 
compliant shell.
-mike


signature.asc
Description: This is a digitally signed message part.
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


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

2012-11-09 Thread Eitan Adler
On 10 November 2012 00:41, Mike Frysinger  wrote:
> ironic considering you're espousing a change to support crap systems that
> aren't relevant.

I won't comment on this.

> if the script is written in bash and is intended to be, then
> /bin/bash is the correct answer.

Absolutely false. /usr/local/bin or /opt/bin might be the correct location.

> if the script is intended to be POSIX shell,
> then /bin/sh is the correct answer.

Agreed.

> using env is just stupid.

only if you don't care about portability.

POSIX > env > absolute path


-- 
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-09 Thread Mike Frysinger
On Tuesday 06 November 2012 11:53:12 Eitan Adler wrote:
> 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?

ironic considering you're espousing a change to support crap systems that 
aren't relevant.  if the script is written in bash and is intended to be, then 
/bin/bash is the correct answer.  if the script is intended to be POSIX shell, 
then /bin/sh is the correct answer.  using env is just stupid.
-mike


signature.asc
Description: This is a digitally signed message part.
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


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

2012-11-07 Thread Joel Rosdahl
On 5 November 2012 18:55, Andrew Stubbs  wrote:

> The test script fails with shells other than bash. At least dash
> doesn't work.


test.sh is intended to work even on Solaris's /bin/sh, which is even more
restricted than dash. Current test.sh on master and maint works well with
dash for me. Please report any failures you see.

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


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

2012-11-07 Thread Andrew Stubbs

On 06/11/12 16:53, Eitan Adler wrote:

Perhaps you should get a better version of env?


Perhaps I should! I'm running Ubuntu 12.10, so I'm surprised about that. 
But even if I did there would be many others with the same issue.



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.


Ok, well, I couldn't identify the exact problem either, so this seemed 
like the easiest fix, and anyway bashisms are nice, if they're allowed.


Feel free to propose an alternative patch. :)

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


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

2012-11-05 Thread g . esp


- Mail original -
> De: "Andrew Stubbs" 
> À: ccache@lists.samba.org
> Envoyé: Lundi 5 Novembre 2012 18:55:10
> Objet: [ccache] [PATCH] Use bash for test.sh.
> 
> The test script fails with shells other than bash. At least dash
> doesn't work.
> 
> Signed-off-by: Andrew Stubbs 
> ---
>   test.sh |2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/test.sh b/test.sh
> index 4c78617..a334f62 100755
> --- a/test.sh
> +++ b/test.sh
> @@ -1,4 +1,4 @@
> -#!/bin/sh
> +#!/bin/bash
>   #
>   # A simple test suite for ccache.
>   #
> --

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

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-05 Thread Eitan Adler
On 5 November 2012 12:55, Andrew Stubbs  wrote:
> The test script fails with shells other than bash. At least dash
> doesn't work.
>
> Signed-off-by: Andrew Stubbs 
> ---
>  test.sh |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/test.sh b/test.sh
> index 4c78617..a334f62 100755
> --- a/test.sh
> +++ b/test.sh
> @@ -1,4 +1,4 @@
> -#!/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.

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