On 24 March 2011 16:06, Mattias Gaertner <nc-gaert...@netcologne.de> wrote:
> Hi all,
>
> I would like to execute small pascal programs like normal unix
> scripts. For example:
>
> #!/usr/bin/instantfpc
> begin
>  writeln('shebang executed');
> end.
>
> Has anyone already written a tool, that compiles and
> runs the program?

Using an idea I saw somewhere else, I've done this:

hcv@technical09:~/source/fpc_script$ ls -l
total 4
-rwxr-xr-x 1 hcv hcv 148 Mar 24 16:38 fpc_script.pp

hcv@technical09:~/source/fpc_script$ cat fpc_script.pp
// 2>/dev/null; fpc fpc_script.pp &> /dev/null && exec ./fpc_script "$@"; exit
program fpc_script;
begin
        writeln('hi there, from a script!');
end.

hcv@technical09:~/source/fpc_script$ ./fpc_script.pp
hi there, from a script!

It would be nice to have #!fpc --run

Henry
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to