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

From: Jens Axel Søgaard <jensaxel>
Date: Wed Nov 15 11:19:57 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
Received on Wed Nov 15 2006 - 11:18:03 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:00 UTC