script-checker 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/sh
  2. #
  3. # This file is part of Hercules.
  4. # http://herc.ws - http://github.com/HerculesWS/Hercules
  5. #
  6. # Copyright (C) 2013-2015 Hercules Dev Team
  7. # Copyright (C) 2013 Haru <haru@dotalux.com>
  8. #
  9. # Hercules is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, either version 3 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. # Base Author: Haru @ http://herc.ws
  22. ORIG_CWD="$(pwd)"
  23. BASEDIR="$(dirname "$0")"
  24. EXECUTABLE="./map-server"
  25. cd "${BASEDIR}"
  26. if [ -z "$1" ]; then
  27. echo "No file specified."
  28. echo "Usage: $0 <path to the script>"
  29. echo " (you may use a relative or absolute path)"
  30. exit 1
  31. fi
  32. case "$1" in
  33. /*)
  34. FILE="$1"
  35. ;;
  36. *)
  37. FILE="${ORIG_CWD}/$1"
  38. ;;
  39. esac
  40. if [ ! -x "$EXECUTABLE" ]; then
  41. exit 1
  42. fi
  43. while [ -n "$1" ]; do
  44. [ -n "$FILES" ] && FILES="${FILES}!"
  45. if [[ "$1" =~ ^\/ ]]; then
  46. FILES="${FILES}--load-script!$1"
  47. else
  48. FILES="${FILES}--load-script!${ORIG_CWD}/$1"
  49. fi
  50. shift
  51. done
  52. # We assume that filenames don't contain exclamation marks.
  53. IFS=!
  54. "$EXECUTABLE" --script-check $FILES 2>&1