You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
569 B

  1. #!/bin/sh
  2. set -eu
  3. # find root of the "workspace"
  4. find_repo_workspace_root() {
  5. if [ -d "$1/.repo" ]; then
  6. echo "$1"
  7. elif [ "${1:-/}" != / ]; then
  8. find_repo_workspace_root "${1%/*}"
  9. fi
  10. }
  11. WS="$(find_repo_workspace_root "$PWD")"
  12. if [ -z "$WS" ]; then
  13. # find root of .git repository
  14. WS="$(git rev-parse --show-superproject-working-tree 2> /dev/null || true)"
  15. [ -d "$WS" ] || WS="$(git rev-parse --show-toplevel 2> /dev/null || true)"
  16. fi
  17. if [ -d "$WS" ]; then
  18. if [ -x "$WS/run.sh" ]; then
  19. exec "$WS/run.sh" "$@"
  20. fi
  21. fi
  22. if [ "$#" -gt 0 ]; then
  23. exec "$@"
  24. fi