Erlang:从命令行调用erl -eval永远不会退出

Pio*_*zyk 0 erlang erl erlang-shell

我有一个简单的Erlang命令,我想通过它来调用erl -eval(编译erlydtl模板,如erlydtl页面所述).

当我从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
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试通过erl -eval(我想从.bat文件运行)时:

erl -pa ebin deps\erlydtl\ebin -noshell -eval erlydtl:compile('templates/tictactoe.dtl',tictactoe_dtl,[{out_dir,'ebin'}])
Run Code Online (Sandbox Code Playgroud)

然后该命令完成其工作(模板已编译)但它不会退出,我需要使用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)
Run Code Online (Sandbox Code Playgroud)

错误信息非常恼人,所以我仍然不喜欢这个解决方案.

小智 5

这应该可以解决问题

erl -noshell -eval 'c:ls()' -eval 'init:stop()'
Run Code Online (Sandbox Code Playgroud)

你必须告诉vm关闭.