Hi,
Short: I think to_erl/run_erl have been minorly broken for about ten years.
The actual problem
Back in 2013, the protocol between to_erl and run_erl was changed. The opening byte used to be 022 (^R), but then it was changed to 014 (^L). run_erl displays half the handshake to the user, which was harmless with 022 but causes a clear-screen with 014, thus making the banner from ‘to_erl’ disappear.
The protocol was changed in 0d4a6b50, “on behalf of shell search”, probably to avoid having search-backwards (^R) trigger the handshake.
Old behaviour (e.g. R14B03)
/usr/local/src/otp_src_R14B03/bin >./x86_64-unknown-linux-gnu/to_erl
Attaching to /tmp/erlang.pipe.3 (^D to exit)
1> // this is the erlang shell
New behaviour (e.g. R26)
/usr/local/src/otp_src_26.0.2/bin > ./x86_64-pc-linux-gnu/to_erl
1> // this is the erlang shell
i.e. the banner “Attaching to…” disappears because the screen gets cleared before you can read it. That messes up alternative shells which have help text in the banner, for instance “press enter to start the shell”.
Patch
--- otp_src_26.0.2/erts/etc/unix/run_erl.c.orig 2023-10-05 20:58:36.116555285 +0200
+++ otp_src_26.0.2/erts/etc/unix/run_erl.c 2023-10-05 21:09:44.403926705 +0200
@@ -714,6 +714,7 @@
if (!got_some && wfd && buf[0] == '\014') {
char wbuf[30];
+ buf[0] = ' '; // re-write ^L in the handshake to a harmless character
int wlen = sn_printf(wbuf,sizeof(wbuf),"[run_erl v%u-%u]\n",
RUN_ERL_HI_VER, RUN_ERL_LO_VER);
outbuf_append(wbuf,wlen);
@@ -1459,5 +1460,3 @@
}
#endif /* DEBUG */
Background
to_erl and run_erl are used to run Erlang in embedded unix-y systems. They’re sort-of a home-made version of ‘Screen’, i.e. they re-direct Erlang’s console input and output to a named pipe so you can start an erlang shell and connect to it later on.
You can try it out yourself. In one window:
cd /usr/local/src/otp_src_26.0.2/bin
export ROOTDIR=/usr/local/src/otp_src_26.0.2
export BINDIR=/usr/local/src/otp_src_26.0.2/bin/x86_64-pc-linux-gnu/
x86_64-pc-linux-gnu/run_erl /tmp/ /tmp/ x86_64-pc-linux-gnu/erlexec
In another window:
./x86_64-pc-linux-gnu/to_erl
Just to show how much this is a re-invention of ‘screen’, you don’t have to run Erlang through it, you can run other things too, like Emacs:
unset DISPLAY
x86_64-pc-linux-gnu/run_erl /tmp/ /tmp/ emacs
This works well enough to play tetris
Historical digression
The manual for run_erl and to_erl includes an archaeological leftover: a set of instructions for running embedded Erlang on a ‘VME board from Force computers’ which apparently had 64 MB or RAM and ran a version of Solaris which needed 17 MB. Great that grandpa had a supercomputer. According to the source, he worked for ETX. Maybe an Ericsson greybeard can remind me what ETX was, I only remember UAB, ERA and EPA.