annotate bin/artisan @ 657:91d7c2e5936c

Remove need to manually switch directory with sud
author nanaya <me@nanaya.pro>
date Sun, 25 Jul 2021 21:36:52 +0900
parents cd80bafc1257
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
594
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
1 #!/bin/sh
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
2 # starts up artisan wherever
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
3
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
4 set -e
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
5 set -u
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
6
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
7 _artisan_path="$(basename "${0}")"
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
8 if [ ! -f "${_artisan_path}" ]; then
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
9 _git_root="$(git rev-parse --show-toplevel 2> /dev/null || true)"
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
10 _hg_root="$(hg root 2> /dev/null || true)"
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
11
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
12 for i in "${_git_root}" "${_hg_root}"; do
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
13 [ "${i}" = "" ] && continue
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
14 _new_artisan_path="${i}/${_artisan_path}"
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
15 if [ -f "${_new_artisan_path}" ]; then
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
16 _artisan_path="${_new_artisan_path}"
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
17 break
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
18 fi
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
19 done
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
20 fi
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
21
2ac0fa5ba73c Add artisan convenience script
nanaya <me@myconan.net>
parents:
diff changeset
22 exec php "${_artisan_path}" "${@}"