[fpc-pascal] run pascal programs as scripts

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Apr 23 20:56:34 CEST 2011

On Sat, 23 Apr 2011 20:27:37 +0200
"Ludo Brands" <ludo.brands at free.fr> wrote:

> Nice tool. 
> 2 requests:
> - I would like to select the compiler. I'm typically working with the svn
> version of compiler but have in my PATH a stable version of the compiler.
> >From the sources I can see that the compiler is searched for only in the
> PATH. A simple solution would be to look first for the compiler in the path
> specified in the shebang and, if not found, then in the PATH. 

One solution:
PATH=YourDirectory:$PATH; script.pas

Another solution:
A parameter could be added to instantfpc to specify the compiler.

> - I was going to ask for the possibility of passing parameters to the
> program.

Just like a normal script:

script.pas param1

> Scripts without the possiblity to pass parameters are not really
> usefull. 

Indeed, that would be total crap.

> And we do't want to put parameters in the program neither since it
> would be re-compiled everytime the parameters change. Looking at the source
> I figured out that the compiler parameters stop at the first parameter not
> starting with a "-"

Yes, that parameter is the "script.pas".

> and passes the rest on to the program. Great,needs to be
> added to the documentation, 

This is is how shebang works internally. I didn't know the
internals of shebang until I wrote instantfpc. That's why I think a user
does not need that information.

> but... The cache is compared to the complete
> script, including the shebang. So if a program parameter is changed, the
> program is re-compiled... The shebang is commented out but program
> parameters should  be removed before compare. Recompiling if compiler
> parameters change is OK. 

The shebang contains the parameters for the compiler, not for the


More information about the fpc-pascal mailing list