-
-
Save timonweb/daab7da95e0b99b984ab2526cdde912d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# James Shubin, 2018 | |
# run `make` in the first directory (or its parent recursively) that it works in | |
# https://purpleidea.com/blog/2018/03/10/running-make-from-anywhere/ | |
MF='Makefile' # looks for this file, could look for others, but that's silly | |
CWD=$(pwd) # starting here | |
while true; do | |
if [ -e "$MF" ]; then | |
make $@ # run make! | |
e=$? | |
cd "$CWD" # go home first | |
exit $e # pass on the exit status | |
fi | |
# stop if we get home | |
if [ "$(pwd)" = "$HOME" ]; then | |
cd "$CWD" | |
exit 2 # the exit status of `make` when it errors | |
fi | |
#echo "searching..." | |
cd .. # go up one dir | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment