<?xml version="1.0"?>
<?xml-stylesheet
href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"
?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel rdf:about="http://pear.php.net/bugs/search.php">
    <title>PEAR Bug Search Results</title>
    <link>http://pear.php.net/bugs/search.php?cmd=display&amp;package_name%5B0%5D=System_Command</link>
    <description>Search Results</description>
    <dc:language>en-us</dc:language>
    <dc:creator>pear-webmaster@lists.php.net</dc:creator>
    <dc:publisher>pear-webmaster@lists.php.net</dc:publisher>
    <admin:generatorAgent rdf:resource="http://pear.php.net/bugs"/>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
    <items>
     <rdf:Seq>
      <rdf:li rdf:resource="http://pear.php.net/bug/16558" />
      <rdf:li rdf:resource="http://pear.php.net/bug/14837" />
      <rdf:li rdf:resource="http://pear.php.net/bug/9504" />

     </rdf:Seq>
    </items>
  </channel>

  <image rdf:about="http://pear.php.net/gifs/pearsmall.gif">
    <title>PEAR Bugs</title>
    <url>http://pear.php.net/gifs/pearsmall.gif</url>
    <link>http://pear.php.net/bugs</link>
  </image>

    <item rdf:about="http://pear.php.net/bug/16558">
      <title>System_Command: Feature/Change Request 16558 [Open] Introduce Timeout</title>
      <link>http://pear.php.net/bugs/16558</link>
      <content:encoded><![CDATA[<pre>System_Command Feature/Change Request
Reported by ifeghali
2009-08-31T19:14:24+00:00
PHP: 5.2.5 OS:  Package Version: 1.0.6

Description:
------------
It would be handy to have an option to kill the command if it is running for a given period of time. A good example is here:

http://www.php.net/manual/function.exec.php#89716</pre>]]></content:encoded>
      <description><![CDATA[<pre>System_Command Feature/Change Request
Reported by ifeghali
2009-08-31T19:14:24+00:00
PHP: 5.2.5 OS:  Package Version: 1.0.6

Description:
------------
It would be handy to have an option to kill the command if it is running for a given period of time. A good example is here:

http://www.php.net/manual/function.exec.php#89716</pre>]]></description>
      <dc:date>2009-08-31T19:14:24+00:00</dc:date>
      <dc:creator>ifeghali &amp;#x61;&amp;#116; php &amp;#x64;&amp;#111;&amp;#x74; net</dc:creator>
      <dc:subject>System_Command Feature/Change Request</dc:subject>
    </item>
    <item rdf:about="http://pear.php.net/bug/14837">
      <title>System_Command: Documentation Problem 14837 [Verified] Do not throw exceptions</title>
      <link>http://pear.php.net/bugs/14837</link>
      <content:encoded><![CDATA[<pre>System_Command Documentation Problem
Reported by ifeghali
2008-10-20T15:16:48+00:00
PHP: 5.1.6 OS:  Package Version: 1.0.6

Description:
------------
This package does not throw exceptions like stated in the documentation. It returns PEAR errors instead.</pre>]]></content:encoded>
      <description><![CDATA[<pre>System_Command Documentation Problem
Reported by ifeghali
2008-10-20T15:16:48+00:00
PHP: 5.1.6 OS:  Package Version: 1.0.6

Description:
------------
This package does not throw exceptions like stated in the documentation. It returns PEAR errors instead.</pre>]]></description>
      <dc:date>2009-05-27T05:40:58+00:00</dc:date>
      <dc:creator>ifeghali &amp;#x61;&amp;#116; php &amp;#x64;&amp;#111;&amp;#x74; net</dc:creator>
      <dc:subject>System_Command Documentation Problem</dc:subject>
    </item>
    <item rdf:about="http://pear.php.net/bug/9504">
      <title>System_Command: Feature/Change Request 9504 [Verified] Allow arrays to be passed to pushCommand as command line arguments</title>
      <link>http://pear.php.net/bugs/9504</link>
      <content:encoded><![CDATA[<pre>System_Command Feature/Change Request
Reported by joshualross
2006-11-29T20:47:53+00:00
PHP: 5.1.6 OS: Any Package Version: 1.0.5

Description:
------------
System_Command version 1.0.5

It would be beneficial if arguments to pushCommand could be sent as Arrays.  In the case I am dealing with I am attempting to zip a large list of files from different directories.  The list of files is in an array.  I suggest a method that handles arrays by recursing through them.  I successfully tested the following rewrite with and without arrays:

Command.php@ line 313:
        $argv = func_get_args();
        array_shift($argv);
//        foreach($argv as $arg) {
//            if (is_array($arg)) {
//
//
//            if (strpos($arg, '-') === 0) {
//                $command .= ' ' . $arg; 
//            }
//            elseif ($arg != '') {
//                $command .= ' ' . escapeshellarg($arg);
//            }
//        }
        $command .= $this-&gt;_processArgv($argv);


Then add the following method:

    /**
     * Used to recursively escape command line arguments
     *
     * @param  array $argv Arguments for command 
     *
     * @access private
     * @return string 
     */
    function _processArgv($argv) {
        $cmd = '';
        foreach($argv as $arg) {
            if (is_array($arg)) {
            	$cmd .= $this-&gt;_processArgv($arg);
            }
            elseif (strpos($arg, '-') === 0) {
                $cmd .= ' ' . $arg; 
            }
            elseif ($arg != '') {
                $cmd .= ' ' . escapeshellarg($arg);
            }
        }
        return $cmd;
    }


I hope this can be implemented.  ;)

Test script:
---------------
$out_file = '/tmp/test.zip';
$files = array('/tmp/text1.txt', '/tmp/text2.txt');
$options = 'mj9';
$cmd = new System_Command();
$cmd-&gt;pushCommand('zip', '-' . $options, $out_file, $files);
$rc = $cmd-&gt;execute();

Expected result:
----------------
A command like this:
/usr/bin/zip -mj9 '/tmp/test.zip' '/tmp/text1.txt' '/tmp/text2.txt'

Actual result:
--------------
Above returns:
/usr/bin/zip -mj9 '/tmp/test.zip' 'Array'

If I loop through the files adding a space between files like this:
foreach ($files as $file) {
    $to_zip .= ' ' . $file;
}

Result:
/usr/bin/zip -mj9 '/tmp/test.zip' '/tmp/text1.txt /tmp/text2.txt'

The entire string is quoted as it should be but then the command reads the space as part of the filename, hence one long filename instead of multiple files.</pre>]]></content:encoded>
      <description><![CDATA[<pre>System_Command Feature/Change Request
Reported by joshualross
2006-11-29T20:47:53+00:00
PHP: 5.1.6 OS: Any Package Version: 1.0.5

Description:
------------
System_Command version 1.0.5

It would be beneficial if arguments to pushCommand could be sent as Arrays.  In the case I am dealing with I am attempting to zip a large list of files from different directories.  The list of files is in an array.  I suggest a method that handles arrays by recursing through them.  I successfully tested the following rewrite with and without arrays:

Command.php@ line 313:
        $argv = func_get_args();
        array_shift($argv);
//        foreach($argv as $arg) {
//            if (is_array($arg)) {
//
//
//            if (strpos($arg, '-') === 0) {
//                $command .= ' ' . $arg; 
//            }
//            elseif ($arg != '') {
//                $command .= ' ' . escapeshellarg($arg);
//            }
//        }
        $command .= $this-&gt;_processArgv($argv);


Then add the following method:

    /**
     * Used to recursively escape command line arguments
     *
     * @param  array $argv Arguments for command 
     *
     * @access private
     * @return string 
     */
    function _processArgv($argv) {
        $cmd = '';
        foreach($argv as $arg) {
            if (is_array($arg)) {
            	$cmd .= $this-&gt;_processArgv($arg);
            }
            elseif (strpos($arg, '-') === 0) {
                $cmd .= ' ' . $arg; 
            }
            elseif ($arg != '') {
                $cmd .= ' ' . escapeshellarg($arg);
            }
        }
        return $cmd;
    }


I hope this can be implemented.  ;)

Test script:
---------------
$out_file = '/tmp/test.zip';
$files = array('/tmp/text1.txt', '/tmp/text2.txt');
$options = 'mj9';
$cmd = new System_Command();
$cmd-&gt;pushCommand('zip', '-' . $options, $out_file, $files);
$rc = $cmd-&gt;execute();

Expected result:
----------------
A command like this:
/usr/bin/zip -mj9 '/tmp/test.zip' '/tmp/text1.txt' '/tmp/text2.txt'

Actual result:
--------------
Above returns:
/usr/bin/zip -mj9 '/tmp/test.zip' 'Array'

If I loop through the files adding a space between files like this:
foreach ($files as $file) {
    $to_zip .= ' ' . $file;
}

Result:
/usr/bin/zip -mj9 '/tmp/test.zip' '/tmp/text1.txt /tmp/text2.txt'

The entire string is quoted as it should be but then the command reads the space as part of the filename, hence one long filename instead of multiple files.</pre>]]></description>
      <dc:date>2009-06-01T17:38:34+00:00</dc:date>
      <dc:creator>joshualross &amp;#x61;&amp;#116; gmail &amp;#x64;&amp;#111;&amp;#x74; com</dc:creator>
      <dc:subject>System_Command Feature/Change Request</dc:subject>
    </item>
</rdf:RDF>
