mirror of
https://github.com/envmodules/modules.git
synced 2026-06-14 00:42:43 +08:00
Update profile script for sh-like shells to only source sh or bash initialization script when BASH environment variable is found set. Fixes #473
22 lines
423 B
Bash
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
|