-
Notifications
You must be signed in to change notification settings - Fork 0
/
which-shell
53 lines (48 loc) · 1.77 KB
/
which-shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Sourced script: which-shell -*- mode: sh; -*-
#
# Purpose : Identify active shell sourcing this file. Store result in usrhome__running_shell
# Created : Thursday, April 11 2024.
# Author : Pierre Rouleau <prouleau001@gmail.com>
# Time-stamp: <2024-06-10 11:41:44 EDT, updated by Pierre Rouleau>
# ----------------------------------------------------------------------------
# Module Description
# ------------------
#
# This simple script is meant to be sourced inside another sourced script.
# It identifies the running shell (zsh or Bash only) by writing the shell
# name into the usrhome__running_shell environment variable.
# ----------------------------------------------------------------------------
# Code
# ----
#
# Set `usrhome__running_shell' to zsh, bash or unsupported.
# Set `USRHOME_SHELL' to zsh, bash, ksh, sh, or unknown
# Identify what (Bourne compatible) shell this is running.
# Store result in $USRHOME_SHELL so further code can depend
# on the shell type. Credit: https://unix.stackexchange.com/a/72475/473577
# Not yet exported.
# Also set usrhome__running_shell to "zsh", "bash" or "unsupported"
# shellcheck disable=SC2034
if test -n "$ZSH_VERSION"; then
USRHOME_SHELL="zsh"
usrhome__running_shell="zsh"
elif test -n "$BASH_VERSION"; then
USRHOME_SHELL="bash"
usrhome__running_shell="bash"
elif test -n "$KSH_VERSION"; then
USRHOME_SHELL="ksh"
usrhome__running_shell="unsupported"
elif test -n "$FCEDIT"; then
USRHOME_SHELL="ksh"
usrhome__running_shell="unsupported"
elif test -n "$PS3"; then
USRHOME_SHELL="unknown"
usrhome__running_shell="unsupported"
else
USRHOME_SHELL="sh"
usrhome__running_shell="unsupported"
fi
# ----------------------------------------------------------------------------
# Local Variables:
# sh-shell: sh
# End: