File 4221-Make-shell-hints-configurable.patch of Package erlang

From 14532fb0169d7daf2298d493c97dc1ccca60ba9b Mon Sep 17 00:00:00 2001
From: Hans Svensson <hanssv@gmail.com>
Date: Wed, 20 Aug 2025 08:48:45 +0200
Subject: [PATCH 1/2] Make shell hints configurable

The hints in the shell gets rather annoying when you actually do work in
the shell. This adds the possibility to disable them (default is on) via
an STDLIB application variable `shell_hints`, and/or `shell:hints/1`.
---
 lib/stdlib/doc/stdlib_app.md |  3 +++
 lib/stdlib/src/shell.erl     | 24 ++++++++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/lib/stdlib/doc/src/stdlib_app.xml b/lib/stdlib/doc/src/stdlib_app.xml
index 5799b6ca06..ab87a6caf2 100644
--- a/lib/stdlib/doc/src/stdlib_app.xml
+++ b/lib/stdlib/doc/src/stdlib_app.xml
@@ -146,6 +146,10 @@ Eshell V13.0.2  (abort with ^G)
         <p>Can be used to determine how the Erlang shell outputs lists of
           integers.</p>
       </item>
+      <tag><marker id="shell_hints"/><c>shell_hints = boolean()</c></tag>
+      <item>
+        <p>Can be used to enable/disable printing of helpful hints in the shell.</p>
+      </item>
     </taglist>
   </section>
 
diff --git a/lib/stdlib/src/shell.erl b/lib/stdlib/src/shell.erl
index f35589608c..fbebabdf37 100644
--- a/lib/stdlib/src/shell.erl
+++ b/lib/stdlib/src/shell.erl
@@ -28,7 +28,8 @@
 -export([get_state/0, get_function/2]).
 -export([start_restricted/1, stop_restricted/0]).
 -export([local_func/0, local_func/1, local_allowed/3, non_local_allowed/3]).
--export([catch_exception/1, prompt_func/1, multiline_prompt_func/1, strings/1]).
+-export([catch_exception/1, prompt_func/1, multiline_prompt_func/1]).
+-export([strings/1, hints/1]).
 -export([format_shell_func/1, erl_pp_format_func/1]).
 -export([start_interactive/0, start_interactive/1]).
 -export([read_and_add_records/5]).
@@ -43,6 +44,7 @@
 -define(DEF_CATCH_EXCEPTION, false).
 -define(DEF_PROMPT_FUNC, default).
 -define(DEF_STRINGS, true).
+-define(DEF_HINTS, true).
 
 -define(RECORDS, shell_records).
 
@@ -790,7 +792,10 @@ shell_cmd(Es, Eval, Bs, RT, FT, Ds, W) ->
     shell_rep(Eval, Bs, RT, FT, Ds).
 
 shell_rep(Ev, Bs0, RT, FT, Ds0) ->
-    shell_rep(Ev, Bs0, RT, FT, Ds0, 5000).
+    case application:get_env(stdlib, shell_hints, true) =/= false of
+      true  -> shell_rep(Ev, Bs0, RT, FT, Ds0, 5000);
+      false -> shell_rep(Ev, Bs0, RT, FT, Ds0, infinity)
+    end.
 shell_rep(Ev, Bs0, RT, FT, Ds0, Timeout) ->
     receive
         {shell_rep,Ev,{value,V,Bs,Ds}} ->
@@ -1936,6 +1936,13 @@ erl_pp_format_func(String) ->
 strings(Strings) ->
     set_env(stdlib, shell_strings, Strings, ?DEF_STRINGS).
 
+-spec hints(Hints) -> OldHints when
+      Hints :: boolean(),
+      OldHints :: boolean().
+
+hints(Hints) ->
+    set_env(stdlib, shell_hints, Hints, ?DEF_HINTS).
+
 -spec prompt_width(unicode:chardata()) -> non_neg_integer().
 prompt_width(String) ->
     Encoding =
-- 
2.51.0

openSUSE Build Service is sponsored by