Free Pascal有命令行解释器吗?

时间:2011-10-14 22:23:09

标签: interpreter pascal freepascal shebang fpc

例如,我可以通过在我的Pascal文件中添加一个shebang来使用:

#!/usr/bin/env fpi

1 个答案:

答案 0 :(得分:5)

在fpc的svn trunk中有instantfpc: http://svn.freepascal.org/svn/fpc/trunk/utils/instantfpc/

这是自述文件:

instantfpc
==========

This tool allows to execute pascal programs as unix scripts.
A unix script starts with a shebang #! and the program to execute. For example

#!/usr/bin/env instantfpc
begin
  writeln('It works');
end.

If you save the above file as test.pas and set the execute permission
(chmod a+x) you can execute the script simply with
./test.pas


Installation
============

1. Compile instantfpc.lpi using lazarus, lazbuild or via "fpc instantfpc.lpr"
2. Put the executable "instantfpc" in PATH, for example into
   /usr/bin/instantfpc or ~/bin/instantfpc.

That's all.
Now you can execute pascal programs as scripts.