Skip to content

Commit

Permalink
Fail better when run under /bin/sh.
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet authored and ryanjosephking committed Jun 11, 2012
1 parent 520bd44 commit deeae4d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/assert-decent-shell
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[ -n "$ZSH_VERSION" ] && return 0
if [ -n "$BASH_VERSION" ]; then
# TODO: Find a cleaner way to detect if bash is running as 'sh'.
ps $$ | grep bash >/dev/null 2>&1 && return 0
fi

echo "Attempt to run from some shell we don't (yet?) support."
if type pstree >/dev/null 2>&1; then
pstree -h
else
ps ajhf
fi
return 1

# vim:ft=sh
2 changes: 2 additions & 0 deletions lib/basics
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source ~/.../lib/assert-decent-shell || return

PATH="$HOME/.../bin:$PATH" # needed to bootsrap
eval `... env`
source ~/.../lib/tracefuncs
Expand Down
2 changes: 2 additions & 0 deletions lib/path-manip
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This bash/zsh library contains useful functions for viewing and manipulating
# your PATH environment variable, and other similar environment variables.

source ~/.../lib/assert-decent-shell || return

source ~/.../lib/tracefuncs

# List each directory in your PATH, one per line
Expand Down
3 changes: 3 additions & 0 deletions lib/path-manip.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# (Here for backwards compatibility. This is not actually a /bin/sh script, so
# the .sh name isn't quite right.)

source ~/.../lib/assert-decent-shell || return

source ~/.../lib/path-manip
alias path-list=...path-list
alias path-remove=...path-remove
Expand Down
2 changes: 2 additions & 0 deletions lib/scripting
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source ~/.../lib/assert-decent-shell || return

source "$HOME/.../lib/tracefuncs"
function ...repo {
if [ -z "$1" ]; then
Expand Down
2 changes: 2 additions & 0 deletions lib/set-shellname
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source ~/.../lib/assert-decent-shell || return

if [ -n "$ZSH_VERSION" ]; then
export SHELLNAME=zsh
elif [ -n "$BASH_VERSION" ]; then
Expand Down
2 changes: 2 additions & 0 deletions lib/tracefuncs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source ~/.../lib/assert-decent-shell || return

function ...istracing {
[[ -n "$DOTDOTDOT_TRACE" ]]
}
Expand Down

0 comments on commit deeae4d

Please sign in to comment.