[r6rs-discuss] [Formal] "#! /usr/bin/env" is not "portable." It's Unix-specific.

Jens Axel Søgaard jensaxel at soegaard.net
Wed Nov 15 11:18:03 EST 2006


Alan Watson skrev:
> AndrevanTonder wrote:
>> 4) Take the draft statement "a script is a delimited piece of text"
>>    seriously, realize that the #! line is a delimiter, that
>>    the /Scheme/ script starts after that, and stop confusing
>>    "Scheme scripts" with "Unix script files", preferably by
>>    using a different word for the Scheme whatever.
> 
> +1.
> 
> There are implementation of Scheme that are great for scripting (in the 
> Unix sense), but this does not mean that all Scheme programs are 
> scripts. The #! notation makes no sense whatsoever in the context of a 
> Scheme that functions like a conventional compiler (i.e., is closer to 
> /usr/bin/cc than /bin/sh).
> 
> Do C files have to start with "#!/usr/bin/cc"?

In real life: yes.

The reference manual for the C interpreter CInt contains this:

You can run C++ source file as a command in Linux/UNIX environment if 
you have #! command at the beginning of your script. This technique is 
popular in Linux/UNIX script programming.  In case of Cint, you have to 
have space character between the #! and interpreter name.

Example:
	  $ cat HelloWorld.cxx
	  #! /usr/local/bin/cint
	  int main() {
	    printf("Hello World\n");
	    return 0;
	  }

	  $ chmod +x HelloWorld.cxx
	  $ HelloWorld.cxx


Limitation:
   As described alread, you have to have space character between the #! 
and interpreter name.

   If you give -p(preprocessor) option, the preprocessor will complain 
about #! because C/C++ preprocessor doesn't know about #!.

<http://root.cern.ch/root/Cint.phtml?ref>

-- 
Jens Axel Søgaard




More information about the r6rs-discuss mailing list