瀏覽代碼

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

zhanghongtong 4 年之前
父節點
當前提交
dba37513a1
共有 2 個文件被更改,包括 4 次插入2 次删除
  1. 2 2
      apps/emqx/src/emqx_ctl.erl
  2. 2 0
      apps/emqx/test/emqx_ctl_SUITE.erl

+ 2 - 2
apps/emqx/src/emqx_ctl.erl

@@ -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) ->

+ 2 - 0
apps/emqx/test/emqx_ctl_SUITE.erl

@@ -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(_) ->