aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/c.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2017-09-26 13:25:50 +0200
committerDan Gudmundsson <[email protected]>2017-09-27 16:02:15 +0200
commit73500d2a456023ca36172f5af896d0b1f10853b7 (patch)
tree378af5a7204b55eba7b16e3cbd4ec0fbe845671a /lib/stdlib/src/c.erl
parent44c0da287d683609319b74c25dbade61408501b3 (diff)
downloadotp-73500d2a456023ca36172f5af896d0b1f10853b7.tar.gz
otp-73500d2a456023ca36172f5af896d0b1f10853b7.tar.bz2
otp-73500d2a456023ca36172f5af896d0b1f10853b7.zip
Do not load .erlang from current dir
It may be confusing that "hidden" .erlang is loaded from the current working directory. Use c:erlangrc([Dir1,..]) to search and load .erlang from other places than "$HOME/.erlang". Implies that c:erlangrc() needs to be documented.
Diffstat (limited to 'lib/stdlib/src/c.erl')
-rw-r--r--lib/stdlib/src/c.erl18
1 files changed, 11 insertions, 7 deletions
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.