Created
August 10, 2018 13:18
-
-
Save rk/aa8312e1cba261e86ddbe79a95821e0e to your computer and use it in GitHub Desktop.
artisan command that looks in parent directories for where artisan is located.
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 | |
wanted=$(basename $0) | |
dir=. | |
while [[ ! -x "$dir/$wanted" ]]; do | |
if [[ "$dir" -ef "../$dir" ]]; then | |
echo "$wanted not in the current directory or any of its parents" 1>&2 | |
exit 2 | |
fi | |
dir="../$dir" | |
done | |
dir=$(cd -- "$dir" && pwd) | |
if [[ "$dir/$wanted" -ef "$0" ]]; then | |
echo "Cannot call self." | |
exit 2 | |
fi | |
exec "$dir/$wanted" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment