aboutsummaryrefslogtreecommitdiff
path: root/ksh
diff options
context:
space:
mode:
Diffstat (limited to 'ksh')
-rw-r--r--ksh/shrc.d/ksh.sh21
1 files changed, 14 insertions, 7 deletions
diff --git a/ksh/shrc.d/ksh.sh b/ksh/shrc.d/ksh.sh
index 6c134e88..0045a470 100644
--- a/ksh/shrc.d/ksh.sh
+++ b/ksh/shrc.d/ksh.sh
@@ -5,18 +5,25 @@
# Unfortunately, this isn't very simple, because KSH_VERSION is set by PDKSH
# and derivatives, and in ksh93t+ and above, but not in earlier versions of
-# ksh93.
+# ksh93. To make matters worse, the best way I can find for testing the version
+# makes other shells throw tantrums.
-# If it's not already set, we'll try hard to set it to something before we
-# proceed ...
+# Does the name of our shell have "ksh" in it at all? This is in no way
+# guaranteed. It's just a heuristic that e.g. Bash and Yash shouldn't pass.
+case $0 in
+ *ksh*) ;;
+ *) return ;;
+esac
+
+# If KSH_VERSION is not already set, we'll try hard to set it to something
+# before we proceed ...
if [ -z "$KSH_VERSION" ] ; then
- # Test whether we have content in the .sh.version variable. The odd name
- # causes at least Bash to panic, so we suppress errors, and we run it in a
- # subshell to work around parsing error precedence.
+ # Test whether we have content in the .sh.version variable. Suppress errors
+ # and run it in a subshell to work around parsing error precedence.
( test -n "${.sh.version}" ) 2>/dev/null || return
- # If it is, that's our KSH_VERSION
+ # If that peculiarly named variable was set, then that's our KSH_VERSION
KSH_VERSION=${.sh.version}
fi