【发布时间】:2013-05-28 03:12:31
【问题描述】:
我有一个简单的 Erlang 命令,我想通过 erl -eval 调用它(编译 erlydtl 模板,如 erlydtl page 所述)。
当我从 shell 以交互方式执行此操作时,一切正常,命令立即退出:
erl -pa ebin deps\erlydtl\ebin Eshell V5.9.3.1 (abort with ^G)
1> erlydtl:compile('templates/tictactoe.dtl',tictactoe_dtl,[{out_dir,'ebin'}]).
ok
但是当我尝试通过erl -eval 执行此操作时(我想从 .bat 文件运行它):
erl -pa ebin deps\erlydtl\ebin -noshell -eval erlydtl:compile('templates/tictactoe.dtl',tictactoe_dtl,[{out_dir,'ebin'}])
然后命令完成它的工作(模板已编译)但它没有退出,我需要使用 ctrl+c 手动终止 shell 进程(我在 Windows 下工作)。
我只希望命令编译模板并退出。可能是什么问题?
更新:
一种解决方案可能是在命令末尾附加 exit() 调用,但我最终得到以下结果:
erl -pa ebin deps\erlydtl\ebin -noshell -eval erlydtl:compile('templates/tictactoe.dtl',tictactoe_dtl,[{out_dir,'ebin'}]),exit(success).
{"init terminating in do_boot",success}
Crash dump was written to: erl_crash.dump
init terminating in do_boot (success)
错误信息很烦人,所以我还是不喜欢这个解决方案。
【问题讨论】:
-
另外,您可以使用钢筋构建项目。放在
/templates 目录下支持 Erlydtl 模板编译。 -
我目前使用 rebar 但正在寻找替代方案,因为 rebar 编译工作时间很长。
-
rebar compile skip_deps=true对你来说也很慢吗? -
@WardBekker 感谢您的关注,沃德!是的,我知道
skip_deps=true,我正在使用它。但是rebar compile skip_deps=true完成我非常小的玩具项目需要大约 5 秒左右,即使自上次构建以来没有任何更改!而且由于它是玩具项目,我需要经常进行编译-运行循环。使用erl -make编译对我来说只需要不到 1 秒的时间,并且只重新编译编辑过的文件,所以我决定切换到它并编写快速的小脚本来编译 erlydtl 模板。我们在这里:-)。
标签: erlang erlang-shell erl