From 675b8108486919739dc2e213587489c0daab80cb Mon Sep 17 00:00:00 2001
From: Hans Bolinder
The following control sequences are available:
+ single character (currently onlyThe following control sequences are available:
-2> io:fwrite("|~10.5c|~-10.5c|~5c|~n", [$a, $b, $c]). +1> io:fwrite("|~10.5c|~-10.5c|~5c|~n", [$a, $b, $c]). | aaaaa|bbbbb |ccccc| ok
If the Unicode translation modifier (
-1> io:fwrite("~tc~n",[1024]). +2> io:fwrite("~tc~n",[1024]). \x{400} ok -2> io:fwrite("~c~n",[1024]). +3> io:fwrite("~c~n",[1024]). ^@ ok@@ -462,20 +463,20 @@ ok
This format can be used for printing any object and truncating the output so it fits a specified field:
-3> io:fwrite("|~10w|~n", [{hey, hey, hey}]). +1> io:fwrite("|~10w|~n", [{hey, hey, hey}]). |**********| ok -4> io:fwrite("|~10s|~n", [io_lib:write({hey, hey, hey})]). +2> io:fwrite("|~10s|~n", [io_lib:write({hey, hey, hey})]). |{hey,hey,h| -5> io:fwrite("|~-10.8s|~n", [io_lib:write({hey, hey, hey})]). +3> io:fwrite("|~-10.8s|~n", [io_lib:write({hey, hey, hey})]). |{hey,hey | ok
A list with integers larger than 255 is considered an error if the Unicode translation modifier is not given:
-1> io:fwrite("~ts~n",[[1024]]). +4> io:fwrite("~ts~n",[[1024]]). \x{400} ok -2> io:fwrite("~s~n",[[1024]]). +5> io:fwrite("~s~n",[[1024]]). ** exception exit: {badarg,[{io,format,[<0.26.0>,"~s~n",[[1024]]]}, ...
-5> T = [{attributes,[[{id,age,1.50000},{mode,explicit}, +1> T = [{attributes,[[{id,age,1.50000},{mode,explicit}, {typename,"INTEGER"}], [{id,cho},{mode,explicit},{typename,'Cho'}]]}, {typename,'Person'},{tag,{'PRIVATE',3}},{mode,implicit}]. ... -6> io:fwrite("~w~n", [T]). +2> io:fwrite("~w~n", [T]). [{attributes,[[{id,age,1.5},{mode,explicit},{typename, [73,78,84,69,71,69,82]}],[{id,cho},{mode,explicit},{typena me,'Cho'}]]},{typename,'Person'},{tag,{'PRIVATE',3}},{mode ,implicit}] ok -7> io:fwrite("~62p~n", [T]). +3> io:fwrite("~62p~n", [T]). [{attributes,[[{id,age,1.5}, {mode,explicit}, {typename,"INTEGER"}], @@ -522,7 +523,7 @@ ok
-8> io:fwrite("Here T = ~62p~n", [T]). +4> io:fwrite("Here T = ~62p~n", [T]). Here T = [{attributes,[[{id,age,1.5}, {mode,explicit}, {typename,"INTEGER"}], @@ -532,6 +533,18 @@ Here T = [{attributes,[[{id,age,1.5}, {typename,'Person'}, {tag,{'PRIVATE',3}}, {mode,implicit}] +ok+
When the modifier
+5> S = [{a,"a"}, {b, "b"}]. +6> io:fwrite("~15p~n", [S]). +[{a,"a"}, + {b,"b"}] +ok +7> io:fwrite("~15lp~n", [S]). +[{a,[97]}, + {b,[98]}] ok
-9> io:fwrite("~W~n", [T,9]). +8> io:fwrite("~W~n", [T,9]). [{attributes,[[{id,age,1.5},{mode,explicit},{typename,...}], [{id,cho},{mode,...},{...}]]},{typename,'Person'}, {tag,{'PRIVATE',3}},{mode,implicit}] @@ -558,7 +571,7 @@ okare printed. Anything below this depth is replaced with
-10> io:fwrite("~62P~n", [T,9]). +9> io:fwrite("~62P~n", [T,9]). [{attributes,[[{id,age,1.5},{mode,explicit},{typename,...}], [{id,cho},{mode,...},{...}]]}, {typename,'Person'}, @@ -572,13 +585,13 @@ ok10. A leading dash is printed for negative integers.
The precision field selects base. For example:
-11> io:fwrite("~.16B~n", [31]). +1> io:fwrite("~.16B~n", [31]). 1F ok -12> io:fwrite("~.2B~n", [-19]). +2> io:fwrite("~.2B~n", [-19]). -10011 ok -13> io:fwrite("~.36B~n", [5*36+35]). +3> io:fwrite("~.36B~n", [5*36+35]). 5Z ok@@ -590,10 +603,10 @@ ok
The prefix can be a possibly deep list of characters or an atom.
-14> io:fwrite("~X~n", [31,"10#"]). +1> io:fwrite("~X~n", [31,"10#"]). 10#31 ok -15> io:fwrite("~.16X~n", [-31,"0x"]). +2> io:fwrite("~.16X~n", [-31,"0x"]). -0x1F ok@@ -602,10 +615,10 @@ ok
Like
-16> io:fwrite("~.10#~n", [31]). +1> io:fwrite("~.10#~n", [31]). 10#31 ok -17> io:fwrite("~.16#~n", [-31]). +2> io:fwrite("~.16#~n", [-31]). -16#1F ok@@ -639,10 +652,10 @@ ok
If an error occurs, there is no output. For example:
-18> io:fwrite("~s ~w ~i ~w ~c ~n",['abc def', 'abc def', {foo, 1},{foo, 1}, 65]). +1> io:fwrite("~s ~w ~i ~w ~c ~n",['abc def', 'abc def', {foo, 1},{foo, 1}, 65]). abc def 'abc def' {foo,1} A ok -19> io:fwrite("~s", [65]). +2> io:fwrite("~s", [65]). ** exception exit: {badarg,[{io,format,[<0.22.0>,"~s","A"]}, {erl_eval,do_apply,5}, {shell,exprs,6}, -- cgit v1.2.3 From 07c086c1b9ea74996f20339d42ca91c3411966f5 Mon Sep 17 00:00:00 2001 From: Hans BolinderDate: Fri, 1 Feb 2013 12:24:22 +0100 Subject: [stdlib] Add new SDTLIB application variable 'shell_strings' Use the new function shell:strings/1 to toggle how the Erlang shell outputs lists of integers. --- lib/stdlib/doc/src/shell.xml | 22 ++++++++++++++++++---- lib/stdlib/doc/src/stdlib_app.xml | 9 +++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'lib/stdlib/doc/src') diff --git a/lib/stdlib/doc/src/shell.xml b/lib/stdlib/doc/src/shell.xml index bc2120c37d..7f251c863e 100644 --- a/lib/stdlib/doc/src/shell.xml +++ b/lib/stdlib/doc/src/shell.xml @@ -4,7 +4,7 @@ diff --git a/lib/stdlib/doc/src/stdlib_app.xml b/lib/stdlib/doc/src/stdlib_app.xml index a615c1bf88..2391bb6f03 100644 --- a/lib/stdlib/doc/src/stdlib_app.xml +++ b/lib/stdlib/doc/src/stdlib_app.xml @@ -4,7 +4,7 @@ - 1996 2011 +1996 2013 Ericsson AB. All Rights Reserved. @@ -781,7 +781,7 @@ loop(N) -> - catch_exception(Bool) -> Bool +catch_exception(Bool) -> boolean() Sets the exception handling of the shell Bool = boolean() @@ -801,8 +801,8 @@ loop(N) ->Sets the shell prompt - Sets the shell prompt function to
+PromptFunc . The - previous prompt function is returned.Sets the shell prompt function to
. + The previous prompt function is returned. PromptFunc @@ -827,6 +827,20 @@ loop(N) -> is meant to be called from the shell. ++ + Sets the shell's string recognition flag. ++ +Sets pretty printing of lists to
+. + The previous value of the flag is returned. Strings The flag can also be set by the STDLIB application variable +
+shell_strings . The default is +true which means that lists of integers will be + printed using the string syntax, when possible. The value +false means that no lists will be printed using the + string syntax.- 2005 2010 +2005 2013 Ericsson AB. All Rights Reserved. @@ -51,7 +51,7 @@ This parameter can be used to run the Erlang shell in restricted mode.
-+ shell_catch_exception = bool() shell_catch_exception = boolean() - +
This parameter can be used to set the exception handling of the Erlang shell's evaluator process.
@@ -76,6 +76,11 @@This parameter can be used to determine how many results are saved by the Erlang shell.
+ shell_strings = boolean() - +
-- cgit v1.2.3This parameter can be used to determine how the Erlang + shell outputs lists of integers.
+