Files
modules/init/profile.sh.in
Xavier Delaruelle 9a53011961 init: only source sh or bash init if BASH var is set
Update profile script for sh-like shells to only source sh or bash
initialization script when BASH environment variable is found set.

Fixes #473
2022-09-15 19:44:21 +02:00

22 lines
423 B
Bash

# shellcheck shell=sh
# get current shell name by querying shell variables or looking at parent
# process name
if [ -n "${BASH:-}" ]; then
if [ "${BASH##*/}" = 'sh' ]; then
shell='sh'
else
shell='bash'
fi
elif [ -n "${ZSH_NAME:-}" ]; then
shell=$ZSH_NAME
else
shell=$(@BASENAME@ "$(@PS@ -p $$ -ocomm=)")
fi
if [ -f "@initdir@/$shell" ]; then
. "@initdir@/$shell"
else
. '@initdir@/sh'
fi