Makefile: add pickrand
[cmccabe-bin] / boon
1 #!/usr/bin/env bash
2
3 #
4 # boon
5 #
6 # This script searches all the ancestors of the current directory for a file
7 # named .boon. When it finds one, it sources it.
8 # Then it creates a new shell.
9 #
10 # The idea is to use this to manage environment variables based on paths. 
11 #
12 # Colin Patrick McCabe
13 #
14
15 die() {
16     echo $@
17     exit 1
18 }
19
20 D=.
21 COUNT=0
22 FOUND_BOON=0
23 while true; do
24     if [ -x "${D}/.boon" ]; then
25         cat "${D}/.boon"
26         source "${D}/.boon"
27         FOUND_BOON=1
28     fi
29     D="${D}/.."
30     COUNT=$(($COUNT+1))
31     if [ $COUNT -gt 100 ]; then
32         if [ $FOUND_BOON -eq 0 ]; then
33             die "Error: couldn't find .boon"
34         else
35             exit 0
36         fi
37     fi
38 done
39