Skip to content
This repository
Browse code

Make app/Console/cake pwd insensitive on Mac OS X.

Follow up of [36e15a0].
  • Loading branch information...
commit 02cfacec4174d5e4467c5436de6193448b741866 1 parent 83d307e
Renan Gonçalves authored October 26, 2012
27  app/Console/cake
@@ -17,22 +17,21 @@
17 17
 # @license      MIT License (http://www.opensource.org/licenses/mit-license.php)
18 18
 #
19 19
 ################################################################################
20  
-if [[ `uname` =~ 'Darwin' ]]; then
21  
-	ME=$0
22  
-else
23  
-	ME=$(readlink -f $0)
24  
-fi
25  
-LIB=$(cd -P -- "$(dirname -- "$ME")" && pwd -P) && LIB=$LIB/$(basename -- "$ME")
26 20
 
27  
-while [ -h "$LIB" ]; do
28  
-	DIR=$(dirname -- "$LIB")
29  
-	SYM=$(readlink "$LIB")
30  
-	LIB=$(cd "$DIR" && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
31  
-done
  21
+# Canonicalize by following every symlink of the given name recursively
  22
+canonicalize() {
  23
+	NAME=$1
  24
+	while [ -h "$NAME" ]; do
  25
+		DIR=$(dirname -- "$NAME")
  26
+		SYM=$(readlink "$NAME")
  27
+		NAME=$(cd "$DIR" && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
  28
+	done
  29
+	echo "$NAME"
  30
+}
32 31
 
33  
-LIB=$(dirname -- "$LIB")/
34  
-APP=$(dirname $(cd $(dirname $ME) && pwd))
  32
+CONSOLE=$(dirname $(canonicalize "$0"))
  33
+APP=$(dirname "$CONSOLE")
35 34
 
36  
-exec php -q "$LIB"cake.php -working "$APP" "$@"
  35
+exec php -q $CONSOLE/cake.php -working "$APP" "$@"
37 36
 
38 37
 exit;
32  lib/Cake/Console/Templates/skel/Console/cake
@@ -10,24 +10,28 @@
10 10
 # Licensed under The MIT License
11 11
 # Redistributions of files must retain the above copyright notice.
12 12
 #
13  
-# @copyright		Copyright 2005-2012, Cake Software Foundation, Inc.
14  
-# @link			http://cakephp.org CakePHP(tm) Project
15  
-# @package   		app.Console
16  
-# @since		CakePHP(tm) v 2.0
17  
-# @license		MIT License (http://www.opensource.org/licenses/mit-license.php)
  13
+# @copyright    Copyright 2005-2012, Cake Software Foundation, Inc.
  14
+# @link         http://cakephp.org CakePHP(tm) Project
  15
+# @package      app.Console
  16
+# @since        CakePHP(tm) v 2.0
  17
+# @license      MIT License (http://www.opensource.org/licenses/mit-license.php)
18 18
 #
19 19
 ################################################################################
20  
-LIB=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && LIB=$LIB/$(basename -- "$0")
21 20
 
22  
-while [ -h "$LIB" ]; do
23  
-    DIR=$(dirname -- "$LIB")
24  
-    SYM=$(readlink "$LIB")
25  
-    LIB=$(cd "$DIR" && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
26  
-done
  21
+# Canonicalize by following every symlink of the given name recursively
  22
+canonicalize() {
  23
+	NAME=$1
  24
+	while [ -h "$NAME" ]; do
  25
+		DIR=$(dirname -- "$NAME")
  26
+		SYM=$(readlink "$NAME")
  27
+		NAME=$(cd "$DIR" && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
  28
+	done
  29
+	echo "$NAME"
  30
+}
27 31
 
28  
-LIB=$(dirname -- "$LIB")/
29  
-APP=`pwd`
  32
+CONSOLE=$(dirname $(canonicalize "$0"))
  33
+APP=$(dirname "$CONSOLE")
30 34
 
31  
-exec php -q "$LIB"cake.php -working "$APP" "$@"
  35
+exec php -q $CONSOLE/cake.php -working "$APP" "$@"
32 36
 
33 37
 exit;
20  lib/Cake/Console/cake
@@ -17,17 +17,21 @@
17 17
 # @license      MIT License (http://www.opensource.org/licenses/mit-license.php)
18 18
 #
19 19
 ################################################################################
20  
-LIB=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && LIB=$LIB/$(basename -- "$0")
21 20
 
22  
-while [ -h "$LIB" ]; do
23  
-	DIR=$(dirname -- "$LIB")
24  
-	SYM=$(readlink "$LIB")
25  
-	LIB=$(cd "$DIR" && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
26  
-done
  21
+# Canonicalize by following every symlink of the given name recursively
  22
+canonicalize() {
  23
+	NAME=$1
  24
+	while [ -h "$NAME" ]; do
  25
+		DIR=$(dirname -- "$NAME")
  26
+		SYM=$(readlink "$NAME")
  27
+		NAME=$(cd "$DIR" && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
  28
+	done
  29
+	echo "$NAME"
  30
+}
27 31
 
28  
-LIB=$(dirname -- "$LIB")/
  32
+CONSOLE=$(dirname $(canonicalize "$0"))
29 33
 APP=`pwd`
30 34
 
31  
-exec php -q "$LIB"cake.php -working "$APP" "$@"
  35
+exec php -q $CONSOLE/cake.php -working "$APP" "$@"
32 36
 
33 37
 exit;

0 notes on commit 02cface

Please sign in to comment.
Something went wrong with that request. Please try again.