[fpc-pascal] run pascal programs as scripts
Ludo Brands
ludo.brands at free.fr
Mon Apr 25 10:24:58 CEST 2011
> One solution:
> PATH=YourDirectory:$PATH; script.pas
I prefer to keep the PATH intact. I'll use:
bash -c "PATH=YourDirectory:$PATH; script.pas"
> Another solution:
> A parameter could be added to instantfpc to specify the compiler.
Would be the most elegant solution. I understand the "search in the
directory of calling program first" is not very Linux though.
> 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.
Learned also something new.
Thanks, Ludo
-----Message d'origine-----
De : fpc-pascal-bounces at lists.freepascal.org
[mailto:fpc-pascal-bounces at lists.freepascal.org] De la part de Mattias
Gaertner
Envoyé : samedi 23 avril 2011 20:57
À : fpc-pascal at lists.freepascal.org
Objet : Re: [fpc-pascal] run pascal programs as scripts
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 script.
Mattias
_______________________________________________
fpc-pascal maillist - fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list