[fpc-pascal] run pascal programs as scripts
Robert Wolfe
wolfe.robwolfe at gmail.com
Thu Mar 24 22:35:16 CET 2011
On 3/24/2011 2:27 PM, Mark Morgan Lloyd wrote:
> Michael Van Canneyt wrote:
>> On Thu, 24 Mar 2011, Mattias Gaertner 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?
>>
>> As far as I know, the "!/something just means, start /something, and
>> pass current filename as a commandline param ?
>
> In general, "pass all parameters" allowing that unix doctrine expects
> an implicit zeroeth parameter which is the name of the current program.
>
>> So all your tool has to do is write all except the first line to a
>> temp file, compile temp file and execute it ?
>
> If I recall correctly, Rexx has special handling for the first line
> which- intentionally or otherwise- facilitates shebang handling. Also
> I'm reminded of a Perl option which causes it to throw away anything
> before valid scripting.
>
> Would it be feasible to modify FPC so that it discarded everything
> preceding "program", "unit" etc?
>
It wouldn't be Pascal then :)
More information about the fpc-pascal
mailing list