Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fail better when run under /bin/sh.

  • Loading branch information...
commit deeae4d1e87543ea338eab24082a76ed6dd14ad3 1 parent 520bd44
Ingy döt Net authored ryanjosephking committed
15 lib/assert-decent-shell
... ... @@ -0,0 +1,15 @@
  1 +[ -n "$ZSH_VERSION" ] && return 0
  2 +if [ -n "$BASH_VERSION" ]; then
  3 + # TODO: Find a cleaner way to detect if bash is running as 'sh'.
  4 + ps $$ | grep bash >/dev/null 2>&1 && return 0
  5 +fi
  6 +
  7 +echo "Attempt to run from some shell we don't (yet?) support."
  8 +if type pstree >/dev/null 2>&1; then
  9 + pstree -h
  10 +else
  11 + ps ajhf
  12 +fi
  13 +return 1
  14 +
  15 +# vim:ft=sh
2  lib/basics
... ... @@ -1,3 +1,5 @@
  1 +source ~/.../lib/assert-decent-shell || return
  2 +
1 3 PATH="$HOME/.../bin:$PATH" # needed to bootsrap
2 4 eval `... env`
3 5 source ~/.../lib/tracefuncs
2  lib/path-manip
... ... @@ -1,6 +1,8 @@
1 1 # This bash/zsh library contains useful functions for viewing and manipulating
2 2 # your PATH environment variable, and other similar environment variables.
3 3
  4 +source ~/.../lib/assert-decent-shell || return
  5 +
4 6 source ~/.../lib/tracefuncs
5 7
6 8 # List each directory in your PATH, one per line
3  lib/path-manip.sh
... ... @@ -1,5 +1,8 @@
1 1 # (Here for backwards compatibility. This is not actually a /bin/sh script, so
2 2 # the .sh name isn't quite right.)
  3 +
  4 +source ~/.../lib/assert-decent-shell || return
  5 +
3 6 source ~/.../lib/path-manip
4 7 alias path-list=...path-list
5 8 alias path-remove=...path-remove
2  lib/scripting
... ... @@ -1,3 +1,5 @@
  1 +source ~/.../lib/assert-decent-shell || return
  2 +
1 3 source "$HOME/.../lib/tracefuncs"
2 4 function ...repo {
3 5 if [ -z "$1" ]; then
2  lib/set-shellname
... ... @@ -1,3 +1,5 @@
  1 +source ~/.../lib/assert-decent-shell || return
  2 +
1 3 if [ -n "$ZSH_VERSION" ]; then
2 4 export SHELLNAME=zsh
3 5 elif [ -n "$BASH_VERSION" ]; then
2  lib/tracefuncs
... ... @@ -1,3 +1,5 @@
  1 +source ~/.../lib/assert-decent-shell || return
  2 +
1 3 function ...istracing {
2 4 [[ -n "$DOTDOTDOT_TRACE" ]]
3 5 }

0 comments on commit deeae4d

Please sign in to comment.
Something went wrong with that request. Please try again.