[Tinycc-devel] env executable examples

2012-05-10 Thread Thomas Preud'homme
Greetings everybody,

I've just realized that the env trick to use tcc from the correct place [1] 
doesn't work because neither Linux nor env split arguments at spaces.

[1] See commit 27a428cd0fae475d7377e1dbe218c064ee217d85

Basically /usr/bin/env tcc -run will try to find tcc -run which is then 
obviously not found. Should we go back to the solution proposed in [2] or do 
you have another idea?

[2] cb2138f8b098feb1b51a407343a4b99e25d5b506

Best regards,

Thomas Preud'homme


signature.asc
Description: This is a digitally signed message part.
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] env executable examples

2012-05-10 Thread Thomas Preud'homme
Le jeudi 10 mai 2012 15:50:00, Thomas Preud'homme a écrit :
 Greetings everybody,
 
 I've just realized that the env trick to use tcc from the correct place [1]
 doesn't work because neither Linux nor env split arguments at spaces.
 
 [1] See commit 27a428cd0fae475d7377e1dbe218c064ee217d85
 
 Basically /usr/bin/env tcc -run will try to find tcc -run which is then
 obviously not found. Should we go back to the solution proposed in [2] or
 do you have another idea?
 
 [2] cb2138f8b098feb1b51a407343a4b99e25d5b506
 
 Best regards,
 
 Thomas Preud'homme

Actually I've just realized another solution would be to search for a shebang 
to tcc when there is only one parameter and this is a c file.

This way we could do /usr/bin/env tcc and tcc would know it must run the 
TCC_OUTPUT_MEMORY option. The problem would then be that a file starting with a 
valid shebang could not be compiled  linked with tcc. It would break 
potential script doing tcc $file  ./a.out

What do you think?

Best regards,

Thomas Preud'homme


signature.asc
Description: This is a digitally signed message part.
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] env executable examples

2012-05-10 Thread David Mertens
Couldn't we just create the binary called tcc-run, so users could say

#!/usr/bin/env tcc-run

at the top of their files?

On Thu, May 10, 2012 at 8:53 AM, Thomas Preud'homme robo...@celest.frwrote:

 Le jeudi 10 mai 2012 15:50:00, Thomas Preud'homme a écrit :
  Greetings everybody,
 
  I've just realized that the env trick to use tcc from the correct place
 [1]
  doesn't work because neither Linux nor env split arguments at spaces.
 
  [1] See commit 27a428cd0fae475d7377e1dbe218c064ee217d85
 
  Basically /usr/bin/env tcc -run will try to find tcc -run which is then
  obviously not found. Should we go back to the solution proposed in [2] or
  do you have another idea?
 
  [2] cb2138f8b098feb1b51a407343a4b99e25d5b506
 
  Best regards,
 
  Thomas Preud'homme

 Actually I've just realized another solution would be to search for a
 shebang
 to tcc when there is only one parameter and this is a c file.

 This way we could do /usr/bin/env tcc and tcc would know it must run the
 TCC_OUTPUT_MEMORY option. The problem would then be that a file starting
 with a
 valid shebang could not be compiled  linked with tcc. It would break
 potential script doing tcc $file  ./a.out

 What do you think?

 Best regards,

 Thomas Preud'homme

 ___
 Tinycc-devel mailing list
 Tinycc-devel@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/tinycc-devel




-- 
 Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it. -- Brian Kernighan
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] env executable examples

2012-05-10 Thread grischka

Thomas Preud'homme wrote:

Greetings everybody,

I've just realized that the env trick to use tcc from the correct place [1] 
doesn't work because neither Linux nor env split arguments at spaces.


[1] See commit 27a428cd0fae475d7377e1dbe218c064ee217d85

Basically /usr/bin/env tcc -run will try to find tcc -run which is then 
obviously not found. Should we go back to the solution proposed in [2] or do 
you have another idea?


Why not use just

#!tcc -tun

Otherwise I'd suggest to revert to the original

#!/usr/local/bin/tcc -tun

which of course does not work if user installs tcc elsewhere
but really we should not care.  After all the examples are
for studying purposes in the first place.

--- grischka




[2] cb2138f8b098feb1b51a407343a4b99e25d5b506

Best regards,

Thomas Preud'homme




___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] env executable examples

2012-05-10 Thread Michael Matz

Hi,

On Thu, 10 May 2012, grischka wrote:


[1] See commit 27a428cd0fae475d7377e1dbe218c064ee217d85

Basically /usr/bin/env tcc -run will try to find tcc -run which is then 
obviously not found. Should we go back to the solution proposed in [2] or 
do you have another idea?


Why not use just

#!tcc -tun


Because shebangs are interpreted by the kernel VFS, which doesn't know 
about $PATH, and hence won't find 'tcc' in any path (and therefore the 
execution will fail).  That's what env(1) was intended for, but the linux 
kernel unfortunately supports only exactly one (optional) argument for the 
interpreter, i.e. it breaks with two and more arguments like when the 
shebang is #!env firstarg secondarg.  So, all in all, when you use an 
meta-interpreter (like env) that somehow needs the name of the real 
interpreter as argument (tcc in this case) you can't give further 
arguments to that real interpreter (-run here).



Otherwise I'd suggest to revert to the original

#!/usr/local/bin/tcc -tun


Which again would have the problem of hardcoding the path to tcc into the 
scripts.  You need a meta-interpreter for finding the name of the real 
interpreter, and you can't give further arguments to it.  Hence the best 
suggestion up to now was to create a wrapper script called tcc-run (just 
calling exec tcc -run $1 on its argument), which would be used as 
argument to the 'env' shebang.


Of course, one could also decide to not care, but IMHO Davids above 
suggestion (helper script) is the most satisfying one, given the sorry 
circumstances.



Ciao,
Michael.

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel