[fpc-pascal] run pascal programs as scripts

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Mar 24 18:18:02 CET 2011


On Thu, 24 Mar 2011 16:53:54 +0000
Henry Vermaak <henry.vermaak at gmail.com> wrote:

> On 24 March 2011 16:44, Henry Vermaak <henry.vermaak at gmail.com> wrote:
> > On 24 March 2011 16:06, Mattias Gaertner <nc-gaertnma at 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 at technical09:~/source/fpc_script$ ls -l
> > total 4
> > -rwxr-xr-x 1 hcv hcv 148 Mar 24 16:38 fpc_script.pp
> >
> > hcv at technical09:~/source/fpc_script$ cat fpc_script.pp
> > // 2>/dev/null; fpc fpc_script.pp &> /dev/null && exec ./fpc_script "$@"; exit
> 
> Or even:
> 
> // 2>/dev/null; fpc fpc_script.pp &> build.log && exec ./fpc_script
> "$@" || cat build.log; exit

Nice idea. I didn't know the // 2>/dev/null trick.
It does not work with tcsh.
The working directory must be '.'.
The temp files should go to another directory.


Mattias



More information about the fpc-pascal mailing list