fix(emqx_ctl): fix an error when "~" in the print content

This commit is contained in:
zhanghongtong 2021-08-05 10:07:55 +08:00 committed by Rory Z
parent 835eb84b5d
commit dba37513a1
2 changed files with 4 additions and 2 deletions

View File

@ -136,11 +136,11 @@ help() ->
-spec(print(io:format()) -> ok).
print(Msg) ->
io:format(format(Msg)).
io:format("~s", [format(Msg)]).
-spec(print(io:format(), [term()]) -> ok).
print(Format, Args) ->
io:format(format(Format, Args)).
io:format("~s", [format(Format, Args)]).
-spec(usage([cmd_usage()]) -> ok).
usage(UsageList) ->

View File

@ -67,10 +67,12 @@ t_run_commands(_) ->
t_print(_) ->
ok = emqx_ctl:print("help"),
ok = emqx_ctl:print("~s", [help]),
ok = emqx_ctl:print("~s", [<<"~!@#$%^&*()">>]),
% - check the output of the usage
mock_print(),
?assertEqual("help", emqx_ctl:print("help")),
?assertEqual("help", emqx_ctl:print("~s", [help])),
?assertEqual("~!@#$%^&*()", emqx_ctl:print("~s", [<<"~!@#$%^&*()">>])),
unmock_print().
t_usage(_) ->