root/tags/2.3.0RC2/bin/phing

Revision 151, 1.9 kB (checked in by hans, 2 years ago)

Fixes #74 for unix (sh): Phing commandline args don't support quoting / spaces

  • Property svn:executable set to *
  • Property svn:keywords set to author date id revision
Line 
1 #!/bin/sh
2 # Shell wrapper for Phing
3 # $Id$
4 #
5 # This script will do the following:
6 # - check for PHP_COMMAND env, if found, use it.
7 #   - if not found assume php is on the path
8 # - check for PHING_HOME evn, if found use it
9 #   - if not look for it
10 # - check for PHP_CLASSPATH, if found use it
11 #   - if not found set it using PHING_HOME/classes
12
13
14 # Put all args in quotes
15 phing_exec_debug=false
16 phing_exec_args=
17 for arg in "$@" ; do
18   phing_exec_args="$phing_exec_args \"$arg\""
19 done
20
21 if [ -z "$PHING_HOME" ] ; then
22
23   # echo "WARNING: PHING_HOME environment not set. Attempting to guess."
24
25   # try to find PHING
26   if [ -d /opt/phing ] ; then
27     PHING_HOME=/opt/phing
28   fi
29
30   if [ -d "${HOME}/opt/phing" ] ; then
31     PHING_HOME="${HOME}/opt/phing"
32   fi
33
34   if [ -d "/usr/local/phing" ] ; then
35     PHING_HOME="/usr/local/phing"
36   fi
37
38   if [ -d "${HOME}/usr/phing" ] ; then
39     PHING_HOME="${HOME}/usr/phing"
40   fi
41  
42   ## resolve links - $0 may be a link to phing's home
43   PRG="$0"
44   progname=`basename "$0"`
45   saveddir=`pwd`
46
47   # need this for relative symlinks
48   dirname_prg=`dirname "$PRG"`
49   cd "$dirname_prg"
50  
51   while [ -h "$PRG" ] ; do
52     ls=`ls -ld "$PRG"`
53     link=`expr "$ls" : '.*-> \(.*\)$'`
54     if expr "$link" : '/.*' > /dev/null; then
55         PRG="$link"
56     else
57         PRG=`dirname "$PRG"`"/$link"
58     fi
59   done
60  
61   PHING_HOME=`dirname "$PRG"`/..
62
63   cd "$saveddir"
64
65   # make it fully qualified
66   PHING_HOME=`cd "$PHING_HOME" && pwd`
67  
68   # make it available in PHP via getenv("PHING_HOME")
69   export PHING_HOME
70 fi
71
72 if (test -z "$PHP_COMMAND") ; then
73         # echo "WARNING: PHP_COMMAND environment not set. (Assuming php on PATH)"
74         PHP_COMMAND=php
75         export PHP_COMMAND
76 fi
77
78 if (test -z "$PHP_CLASSPATH") ; then
79         PHP_CLASSPATH=$PHING_HOME/classes
80         export PHP_CLASSPATH
81 fi
82
83 phing_exec_cmd="exec $PHP_COMMAND -d html_errors=off -qC \"$PHING_HOME/bin/phing.php\" -logger phing.listener.AnsiColorLogger $phing_exec_args"
84 if $phing_exec_debug ; then
85   echo $phing_exec_cmd
86 fi
87 eval $phing_exec_cmd
Note: See TracBrowser for help on using the browser.