cake 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env sh
  2. ################################################################################
  3. #
  4. # Cake is a shell script for invoking CakePHP shell commands
  5. #
  6. # CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  7. # Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  8. #
  9. # Licensed under The MIT License
  10. # For full copyright and license information, please see the LICENSE.txt
  11. # Redistributions of files must retain the above copyright notice.
  12. #
  13. # @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. # @link http://cakephp.org CakePHP(tm) Project
  15. # @since 1.2.0
  16. # @license http://www.opensource.org/licenses/mit-license.php MIT License
  17. #
  18. ################################################################################
  19. # Canonicalize by following every symlink of the given name recursively
  20. canonicalize() {
  21. NAME="$1"
  22. if [ -f "$NAME" ]
  23. then
  24. DIR=$(dirname -- "$NAME")
  25. NAME=$(cd -P "$DIR" > /dev/null && pwd -P)/$(basename -- "$NAME")
  26. fi
  27. while [ -h "$NAME" ]; do
  28. DIR=$(dirname -- "$NAME")
  29. SYM=$(readlink "$NAME")
  30. NAME=$(cd "$DIR" > /dev/null && cd $(dirname -- "$SYM") > /dev/null && pwd)/$(basename -- "$SYM")
  31. done
  32. echo "$NAME"
  33. }
  34. CONSOLE=$(dirname -- "$(canonicalize "$0")")
  35. APP=$(dirname "$CONSOLE")
  36. if [ $(basename $0) != 'cake' ]
  37. then
  38. exec php "$CONSOLE"/cake.php $(basename $0) "$@"
  39. else
  40. exec php "$CONSOLE"/cake.php "$@"
  41. fi
  42. exit