From 89bf1b08bbb45fa55d37d708f5aacbbdf2bc7885 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Fri, 7 Oct 2011 22:13:13 -0700 Subject: [PATCH] Add boon Signed-off-by: Colin McCabe --- boon | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) create mode 100755 boon diff --git a/boon b/boon new file mode 100755 index 0000000..7faa332 --- /dev/null +++ b/boon @@ -0,0 +1,40 @@ +#!/bin/bash + +# +# boon +# +# This script searches all the ancestors of the current directory for a file +# named .boon. When it finds one, it sources it. +# Then it creates a new shell. +# +# The idea is to use this to manage environment variables based on paths. +# +# Colin Patrick McCabe +# + +die() { + echo $@ + exit 1 +} + +D=. +COUNT=0 +FOUND_BOON=0 +while true; do + if [ -x "${D}/.boon" ]; then + cat "${D}/.boon" + source "${D}/.boon" + FOUND_BOON=1 + fi + D="${D}/.." + COUNT=$(($COUNT+1)) + if [ $COUNT -gt 100 ]; then + if [ $FOUND_BOON -eq 0 ]; then + die "Error: couldn't find .boon" + else + # start a shell with our new environment + bash + fi + fi +done + -- 1.6.6.rc1.39.g9a42