1

我正在使用“rebar shell”来测试我的应用程序。这被记录为:

启动一个预先加载了项目和 deps 的 shell,类似于

'erl -pa ebin -pa deps/*/ebin'.

如何在“erl”的基础调用中添加额外的参数?例如,我想添加特定于应用程序的环境变量并运行模块/函数。我想调用类似的东西:

 erl -pa ebin -pa deps/*/ebin -browser_spy browser_exe "/my/dir" -run bs_example test

(并且我希望 code:priv_dir 像使用 rebar shell 时一样工作,而上面的 'erl' 命令没有这样做)。

4

1 回答 1

0

你不能

rebar shell实际上不执行erl ...命令,而只是尝试复制其行为

-pa实际上,钢筋只是通过添加路径将自己变成外壳并模仿code:add_pathz

有关实施细节,请参见此处:

shell(_Config, _AppFile) ->
    true = code:add_pathz(rebar_utils:ebin_dir()),
    %% scan all processes for any with references to the old user and save them to
    %% update later
    NeedsUpdate = [Pid || Pid <- erlang:processes(),
        proplists:get_value(group_leader, erlang:process_info(Pid)) == whereis(user)
    ],
    %% terminate the current user
    ok = supervisor:terminate_child(kernel_sup, user),
    %% start a new shell (this also starts a new user under the correct group)
    _ = user_drv:start(),
    %% wait until user_drv and user have been registered (max 3 seconds)
    ok = wait_until_user_started(3000),
    %% set any process that had a reference to the old user's group leader to the
    %% new user process
    _ = [erlang:group_leader(whereis(user), Pid) || Pid <- NeedsUpdate],
    %% enable error_logger's tty output
    ok = error_logger:swap_handler(tty),
    %% disable the simple error_logger (which may have been added multiple
    %% times). removes at most the error_logger added by init and the
    %% error_logger added by the tty handler
    ok = remove_error_handler(3),
    %% this call never returns (until user quits shell)
    timer:sleep(infinity).
于 2015-10-27T20:15:59.020 回答