From aaa692b324eeff0a3884434591a99f72241e5632 Mon Sep 17 00:00:00 2001 From: bol-van Date: Tue, 7 May 2024 20:19:43 +0300 Subject: [PATCH] base.sh: shell_name() --- common/base.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/base.sh b/common/base.sh index 04966c1..ed853aa 100644 --- a/common/base.sh +++ b/common/base.sh @@ -278,6 +278,22 @@ random() echo $(( ($r % ($2-$1+1)) + $1 )) } +shell_name() +{ + [ -n "$SHELL_NAME" ] || { + [ -n "$UNAME" ] || UNAME="$(uname)" + + if [ "$UNAME" = "Linux" ]; then + SHELL_NAME="$(readlink /proc/$$/exe)" + SHELL_NAME="$(basename "$SHELL_NAME")" + else + SHELL_NAME=$(ps -p $$ -o comm=) + fi + + [ -n "$SHELL_NAME" ] || SHELL_NAME=$(basename "$SHELL") + } +} + std_ports() { HTTP_PORTS=${HTTP_PORTS:-80}