Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.2

Bug #16848 Trailing spaces in quoted argument are truncated.
Submitted: 2009-11-30 18:16 UTC
From: rquadling Assigned: izi
Status: Closed Package: Console_CommandLine (version 1.1.1)
PHP Version: 5.3.1 OS: Windows XP SP3
Roadmaps: (Not assigned)    
Subscription  


 [2009-11-30 18:16 UTC] rquadling (Richard Quadling)
Description: ------------ Trailing spaces for arguments which are enclosed in "" are truncated. Running the following script as ... php -n -f test.php " S P A C E S " The CommandLine::parseToken() causes the trim() to take place. Removing it for the example supplied works. I have other scripts which use more complex command lines and they seem to be working fine also. Considering that you cannot have spaces in arguments without the quotes, the spaces should be preserved once quotes are used. With this change, the tests run the same as without the change (but issues exist with the tests - separate bug report). Test script: --------------- <?php require_once 'Console/CommandLine.php'; $o_CommandLineParser = new Console_CommandLine(array('name' => 'Missing trailing spaces')); $o_CommandLineParser->addArgument('prefix', array('description' => 'Prefix')); try { $o_CommandLine = $o_CommandLineParser->parse(); var_dump($o_CommandLine->args); } catch (Exception $e) { $o_CommandLineParser->displayError($e->getMessage()); } Expected result: ---------------- array(1) { ["prefix"]=> string(13) " S P A C E S " } Actual result: -------------- array(1) { ["prefix"]=> string(11) "S P A C E S" }

Comments

 [2009-11-30 18:17 UTC] rquadling (Richard Quadling)
 [2009-11-30 19:10 UTC] izi (David Jean Louis)
Makes sense, and I don't think it breaks backward compatibility. I'll apply your patch, thanks.
 [2009-11-30 22:04 UTC] izi (David Jean Louis)
-Status: Open +Status: Closed -Assigned To: +Assigned To: izi
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.