Permalink
Browse files

fix to allow spaces in filenames (osx compatibility fix)

  • Loading branch information...
Jakobo committed Jun 8, 2009
1 parent 39b3d37 commit fc70e679164a45e921b1d161f51b1c4d575693cf
Showing with 41 additions and 4 deletions.
  1. +1 −0 core/util/analyzer/analyzer.php
  2. +12 −0 core/util/request/request.php
  3. +1 −1 snaptest.php
  4. +27 −3 snaptest.sh
@@ -66,6 +66,7 @@ public function analyzeFile($file) {
// include, and then scan for new classes
include_once $file;
+
$classes = array_diff(get_declared_classes(), $classes);
$output = array();
@@ -25,6 +25,8 @@ public static function unmangleRequest($var) {
* @return string
**/
public static function mangleRequest($var) {
+ $var = str_replace(' ', '\ ', $var);
+
if (SNAP_CGI_MODE) {
return str_replace('.', SNAP_MANGLE_STRING, $var);
}
@@ -133,10 +135,20 @@ public function getLongOptions($request) {
break;
}
+ $prev = '';
foreach ($argv as $idx => $arg) {
if ($idx == 0) {
continue;
}
+
+ // if there is a \ as last char, link to $prev and go again
+ if (strrpos($arg, '\\') + 1 === strlen($arg)) {
+ $prev = $arg.' ';
+ continue;
+ }
+
+ $arg = $prev.$arg;
+ $prev = '';
if (strpos($arg, '--') === FALSE) {
$sequentials[] = $arg;
View
@@ -21,7 +21,7 @@
'analyze' => FALSE,
));
-$path = $options[0];
+$path = str_replace('\ ', ' ', $options[0]);
$out_mode = $options['out'];
$php = $options['php'];
$xtn = $options['match'];
View
@@ -1,14 +1,34 @@
#!/bin/bash
+# Portable version of resolve_symlink to work across multiple
+# *nix flavors.
+function resolve_symlink {
+ SCRIPT=$1 NEWSCRIPT=''
+ until [ "$SCRIPT" = "$NEWSCRIPT" ]; do
+ if [ "${SCRIPT:0:1}" = '.' ]; then SCRIPT=$PWD/$SCRIPT; fi
+ cd $(dirname $SCRIPT)
+ if [ ! "${SCRIPT:0:1}" = '.' ]; then SCRIPT=$(basename $SCRIPT); fi
+ SCRIPT=${NEWSCRIPT:=$SCRIPT}
+ NEWSCRIPT=$(ls -l $SCRIPT | awk '{ print $NF }')
+ done
+ if [ ! "${SCRIPT:0:1}" = '/' ]; then SCRIPT=$PWD/$SCRIPT; fi
+ echo $(dirname $SCRIPT)
+}
+
+
# change to shell script real location
-FPATH=`dirname "$0"`
+FPATH=$(resolve_symlink $0);
+
+# correct pwd to resolve any symlinks and spaces in the name
OPATH=`pwd`
-cd $FPATH;
+# OPATH=`echo $OPATH | sed s/\ /\\\\\\\\\ /`
+
+cd $FPATH
# load options
. getoptx.sh
-cd $OPATH
+cd "$OPATH"
# Auto Locate PHP
PHPX=`which php`
@@ -64,6 +84,8 @@ if [ "$RELPTH" = "RELPTHMATCH" ] ; then
PTH="$OPATH/$PTH"
fi
+PTH=`echo $PTH | sed "s/ /\\\\\\ /g"`;
+
# choke and die if we couldn't auto-find PHP and the user didn't supply
# a valid PHP executable path
if [ -z $PHP ] ; then
@@ -77,6 +99,7 @@ CGI=`$PHP -v | grep cgi | wc -l | sed "s/[^0-9]//g"`
# run php on the snaptest.php file with the commands
if [ "$CGI" = "0" ] ; then
+ # PTH=`echo $PTH | sed "s/ /__S_P_A_C_E__/g"`
CMD="$PHP -q $FPATH/snaptest.php --php=$PHP --nice=$NICE $CMD $PTH"
else
# if we are running in CGI mode, we need to mangle our . characters
@@ -87,4 +110,5 @@ else
CMD="$PHP -q $FPATH/snaptest.php --php=$PHPSAFE $CMDSAFE $PTHSAFE"
fi
+
$CMD

0 comments on commit fc70e67

Please sign in to comment.