summaryrefslogtreecommitdiff
path: root/buildscripts/phing/classes/phing/types/Commandline.php
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts/phing/classes/phing/types/Commandline.php')
-rwxr-xr-x[-rw-r--r--]buildscripts/phing/classes/phing/types/Commandline.php32
1 files changed, 20 insertions, 12 deletions
diff --git a/buildscripts/phing/classes/phing/types/Commandline.php b/buildscripts/phing/classes/phing/types/Commandline.php
index 877179d0..d6b36e14 100644..100755
--- a/buildscripts/phing/classes/phing/types/Commandline.php
+++ b/buildscripts/phing/classes/phing/types/Commandline.php
@@ -1,6 +1,6 @@
<?php
/*
- * $Id: Commandline.php,v 1.11 2005/05/26 13:10:53 mrook Exp $
+ * $Id: 891b349dcd88b825ae99edf53ed4c7ac2c1c2467 $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -41,6 +41,7 @@
*
* @author thomas.haas@softwired-inc.com
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
+ * @package phing.types
*/
class Commandline {
@@ -156,8 +157,10 @@ class Commandline {
* @exception BuildException if the argument contains both, single
* and double quotes.
*/
- public static function quoteArgument($argument) {
- if (strpos($argument, "\"") !== false) {
+ public static function quoteArgument($argument, $escape = false) {
+ if ($escape) {
+ return escapeshellarg($argument);
+ } elseif (strpos($argument, "\"") !== false) {
if (strpos($argument, "'") !== false) {
throw new BuildException("Can't handle single and double quotes in same argument");
} else {
@@ -175,7 +178,7 @@ class Commandline {
* Quotes the parts of the given array in way that makes them
* usable as command line arguments.
*/
- public static function toString($lines) {
+ public static function toString($lines, $escape = false) {
// empty path return empty string
if (!$lines) {
return "";
@@ -187,7 +190,7 @@ class Commandline {
if ($i > 0) {
$result .= ' ';
}
- $result .= self::quoteArgument($lines[$i]);
+ $result .= self::quoteArgument($lines[$i], $escape);
}
return $result;
}
@@ -307,7 +310,7 @@ class Commandline {
/**
* Returns a String that describes the command and arguments
* suitable for verbose output before a call to
- * <code>Runtime.exec(String[])<code>.
+ * <code>Runtime.exec(String[])</code>.
*
* <p>This method assumes that the first entry in the array is the
* executable to run.</p>
@@ -339,7 +342,7 @@ class Commandline {
/**
* Returns a String that describes the arguments suitable for
* verbose output before a call to
- * <code>Runtime.exec(String[])<code>
+ * <code>Runtime.exec(String[])</code>
* @param $args arguments to use (default is to use current class args)
* @param $offset ignore entries before this index
* @return string
@@ -357,9 +360,9 @@ class Commandline {
if (count($args) > $offset) {
$buf .= "s";
}
- $buf .= ":" . Phing::getProperty("line.separator");
+ $buf .= ":" . PHP_EOL;
for ($i = $offset, $alen=count($args); $i < $alen; $i++) {
- $buf .= "'" . $args[$i] . "'" . Phing::getProperty("line.separator");
+ $buf .= "'" . $args[$i] . "'" . PHP_EOL;
}
$buf .= self::DISCLAIMER;
return $buf;
@@ -369,6 +372,8 @@ class Commandline {
/**
* "Inner" class used for nested xml command line definitions.
+ *
+ * @package phing.types
*/
class CommandlineArgument {
@@ -432,10 +437,13 @@ class CommandlineArgument {
/**
* Class to keep track of the position of an Argument.
+ *
+ * <p>This class is there to support the srcfile and targetfile
+ * elements of &lt;execon&gt; and &lt;transform&gt; - don't know
+ * whether there might be additional use cases.</p> --SB
+ *
+ * @package phing.types
*/
-// <p>This class is there to support the srcfile and targetfile
-// elements of &lt;execon&gt; and &lt;transform&gt; - don't know
-// whether there might be additional use cases.</p> --SB
class CommandlineMarker {
private $position;