aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2017-10-17 08:12:41 +0200
committerDan Gudmundsson <[email protected]>2017-10-17 08:12:41 +0200
commit11fcc4b2b4581da4e24b94128a4f38ae98a2f466 (patch)
treec1becd60ffb088d0d21b83e9f24854ec6447bef1 /lib/stdlib
parent34b3ee1079890f523062b5d5613187f413871538 (diff)
parentbaf53defc90c4aa8a4caa6b2c6ead6a1b58df199 (diff)
downloadotp-11fcc4b2b4581da4e24b94128a4f38ae98a2f466.tar.gz
otp-11fcc4b2b4581da4e24b94128a4f38ae98a2f466.tar.bz2
otp-11fcc4b2b4581da4e24b94128a4f38ae98a2f466.zip
Merge branch 'dgud/dot_erlang/OTP-14439'
* dgud/dot_erlang/OTP-14439: fixup! Do not load .erlang from current dir erlc: Do not load .erlang escript: Do not load .erlang dialyzer: Do not load .erlang reltool: Add no_dot_erlang bootfiles Enable usage of no_dot_erlang in bootstrap Do not load .erlang from current dir
Diffstat (limited to 'lib/stdlib')
-rw-r--r--lib/stdlib/doc/src/c.xml9
-rw-r--r--lib/stdlib/src/c.erl18
2 files changed, 20 insertions, 7 deletions
diff --git a/lib/stdlib/doc/src/c.xml b/lib/stdlib/doc/src/c.xml
index 7666699183..697e1715e7 100644
--- a/lib/stdlib/doc/src/c.xml
+++ b/lib/stdlib/doc/src/c.xml
@@ -94,6 +94,15 @@
</func>
<func>
+ <name name="erlangrc" arity="1"/>
+ <fsummary>Load an erlang resource file.</fsummary>
+ <desc>
+ <p>Search <c>PathList</c> and load <c>.erlang</c> resource file if
+ found.</p>
+ </desc>
+ </func>
+
+ <func>
<name name="flush" arity="0"/>
<fsummary>Flush any messages sent to the shell.</fsummary>
<desc>
diff --git a/lib/stdlib/src/c.erl b/lib/stdlib/src/c.erl
index c04a201ce1..9a447af5b7 100644
--- a/lib/stdlib/src/c.erl
+++ b/lib/stdlib/src/c.erl
@@ -668,19 +668,23 @@ lm() ->
[l(M) || M <- mm()].
%% erlangrc(Home)
-%% Try to run a ".erlang" file, first in the current directory
-%% else in home directory.
+%% Try to run a ".erlang" file in home directory.
+
+-spec erlangrc() -> {ok, file:filename()} | {error, term()}.
erlangrc() ->
case init:get_argument(home) of
{ok,[[Home]]} ->
erlangrc([Home]);
_ ->
- f_p_e(["."], ".erlang")
+ {error, enoent}
end.
-erlangrc([Home]) ->
- f_p_e([".",Home], ".erlang").
+-spec erlangrc(PathList) -> {ok, file:filename()} | {error, term()}
+ when PathList :: [Dir :: file:name()].
+
+erlangrc([Home|_]=Paths) when is_list(Home) ->
+ f_p_e(Paths, ".erlang").
error(Fmt, Args) ->
error_logger:error_msg(Fmt, Args).
@@ -692,11 +696,11 @@ f_p_e(P, F) ->
{error, E={Line, _Mod, _Term}} ->
error("file:path_eval(~tp,~tp): error on line ~p: ~ts~n",
[P, F, Line, file:format_error(E)]),
- ok;
+ {error, E};
{error, E} ->
error("file:path_eval(~tp,~tp): ~ts~n",
[P, F, file:format_error(E)]),
- ok;
+ {error, E};
Other ->
Other
end.