forked from skx/sysadmin-util
-
Notifications
You must be signed in to change notification settings - Fork 0
/
which-shell
executable file
·60 lines (51 loc) · 881 Bytes
/
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
54
55
56
57
58
59
60
#!/bin/sh
#
# About
# -----
# Identify the shell we're running under.
#
#
# License
# -------
#
# Copyright (c) 2013 by Steve Kemp. All rights reserved.
#
# This script is free software; you can redistribute it and/or modify it under
# the same terms as Perl itself.
#
# The LICENSE file contains the full text of the license.
#
#
#
# Easy cases first
#
if test -n "$ZSH_VERSION"; then
s=zsh
elif test -n "$BASH_VERSION"; then
s=bash
elif test -n "$KSH_VERSION"; then
s=ksh
elif test -n "$FCEDIT"; then
s=ksh
fi
#
# If we found a result then we're done.
#
if [ ! -z "$s" ]; then
echo $s
exit 0
fi
#
# If we have readlink, and /proc/$$/exe then use that
#
if [ -e /proc/$$/exe ]; then
if ( which readlink >/dev/null 2>/dev/null ); then
basename $(readlink /proc/$$/exe)
exit 0
fi
fi
#
# Fallback
#
echo "unknown"
exit 0