File 9311-erts-Remove-some-external-commands-in-Unix-scripts.patch of Package erlang

From 4007cdba0af228d4a0ef635ca5f1e301311cb9a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20de=20Bretagne?=
 <jerome.debretagne@gmail.com>
Date: Sun, 18 Jan 2026 21:14:21 +0100
Subject: [PATCH] erts: Remove some external commands in Unix scripts

Remove calls to some external utilities (awk, basename, sed) in the
erl and start_erl scripts, replacing them with POSIX shell parameter
expansion and 'read' built-ins.

This improves compatibility with embedded systems and restricted
environments where these tools may be missing, particularly on older
releases of Android.

Notes on the shell built-ins used:

- "${0##*/}": A POSIX parameter expansion that removes the longest
  prefix matching '*/'. This pattern matches everything up to and
  including the last slash, effectively performing a 'basename'
  operation entirely within the shell.

- 'read -r VAR1 VAR2 < File': Read the first line of a file and
  assigns the first two space-separated words to each variable,
  replacing the 2 external calls to 'awk'.
---
 erts/etc/unix/erl.src.src   | 2 +-
 erts/etc/unix/start_erl.src | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/erts/etc/unix/erl.src.src b/erts/etc/unix/erl.src.src
index 6167b167b2..0e59807c61 100644
--- a/erts/etc/unix/erl.src.src
+++ b/erts/etc/unix/erl.src.src
@@ -51,7 +51,7 @@ fi
 
 BINDIR="$ROOTDIR/erts-%VSN%/bin"
 EMU=%EMULATOR%%EMULATOR_NUMBER%
-PROGNAME=`basename "$0"`
+PROGNAME="${0##*/}"
 export EMU
 export ROOTDIR
 export BINDIR
diff --git a/erts/etc/unix/start_erl.src b/erts/etc/unix/start_erl.src
index 643cd1dd5c..69753503d6 100644
--- a/erts/etc/unix/start_erl.src
+++ b/erts/etc/unix/start_erl.src
@@ -34,12 +34,11 @@ shift
 DataFile=$1
 shift
 
-ERTS_VSN=`awk '{print $1}' $DataFile`
-VSN=`awk '{print $2}' $DataFile`
+read -r ERTS_VSN VSN _ < "$DataFile"
 
 BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
 EMU=beam
-PROGNAME=`echo $0 | sed 's/.*\///'`
+PROGNAME="${0##*/}"
 export EMU
 export ROOTDIR
 export BINDIR
-- 
2.51.0

openSUSE Build Service is sponsored by