Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added `which-shell`.

  • Loading branch information...
commit 37ba22dddf5aa999a64d7a3700fadf21f8de28e4 1 parent b79e54e
@skx authored
Showing with 76 additions and 0 deletions.
  1. +16 −0 README.md
  2. +60 −0 which-shell
View
16 README.md
@@ -213,6 +213,22 @@ Trivial (ba)sh alternatives:
+which-shell
+-----------
+
+Identify the shell we're running under.
+
+For example:
+
+ $ which-shell
+ dash
+
+Existing alternatives:
+
+* `ls -l /bin/sh`
+
+
+
with-lock
---------
View
60 which-shell
@@ -0,0 +1,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
Please sign in to comment.
Something went wrong with that request. Please try again.