Skip to content

Instantly share code, notes, and snippets.

@rk
Created August 10, 2018 13:18
Show Gist options
  • Save rk/aa8312e1cba261e86ddbe79a95821e0e to your computer and use it in GitHub Desktop.
Save rk/aa8312e1cba261e86ddbe79a95821e0e to your computer and use it in GitHub Desktop.
artisan command that looks in parent directories for where artisan is located.
#!/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