File 4111-erts-Print-string-that-failed-to-eval.patch of Package erlang

From a393cd27e02df1c5cd8ea4d1035c5efba92dcccb Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Tue, 9 Aug 2022 16:20:51 +0200
Subject: [PATCH] erts: Print string that failed to eval

With the way quoting is done in various shells it is not
always obvious what the string entered actually was so we
print it to help the user debug.
---
 erts/preloaded/ebin/init.beam | Bin 61584 -> 61568 bytes
 erts/preloaded/src/init.erl   |  23 +++++++++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/erts/preloaded/src/init.erl b/erts/preloaded/src/init.erl
index 5ea349511d..ceee24e629 100644
--- a/erts/preloaded/src/init.erl
+++ b/erts/preloaded/src/init.erl
@@ -1225,14 +1225,22 @@ start_it([]) ->
     ok;
 start_it({eval,Bin}) ->
     Str = b2s(Bin),
-    {ok,Ts,_} = erl_scan:string(Str),
-    Ts1 = case reverse(Ts) of
-	      [{dot,_}|_] -> Ts;
-	      TsR -> reverse([{dot,erl_anno:new(1)} | TsR])
-	  end,
-    {ok,Expr} = erl_parse:parse_exprs(Ts1),
-    {value, _Value, _Bs} = erl_eval:exprs(Expr, erl_eval:new_bindings()),
-    ok;
+    try
+        {ok,Ts,_} = erl_scan:string(Str),
+        Ts1 = case reverse(Ts) of
+                  [{dot,_}|_] -> Ts;
+                  TsR -> reverse([{dot,erl_anno:new(1)} | TsR])
+              end,
+        {ok,Expr} = erl_parse:parse_exprs(Ts1),
+        {value, _Value, _Bs} = erl_eval:exprs(Expr, erl_eval:new_bindings()),
+        ok
+    catch E:R ->
+            ST = erlang:get_stacktrace(),
+            erlang:display_string(
+              binary_to_list(
+                iolist_to_binary(["Failed to eval: ",Bin,"\n"]))),
+            erlang:raise(E,R,ST)
+    end;
 start_it([_|_]=MFA) ->
     case MFA of
 	[M]        -> M:start();
-- 
2.35.3

openSUSE Build Service is sponsored by