FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=16848&edit=1

ID: 16848
Updated by: izi@php.net
Reported By: RQuadling at GMail dot com
Summary: Trailing spaces in quoted argument are truncated.
Status: Open
Type: Bug
Package: Console_CommandLine
Operating System: Windows XP SP3
Package Version: 1.1.1
PHP Version: 5.3.1
Roadmap Versions:
New Comment:

Makes sense, and I don't think it breaks backward compatibility.
I'll apply your patch, thanks.


Previous Comments:
------------------------------------------------------------------------

[2009-11-30 13:17:29] rquadling

Added #patch
bug:16848;patch:Console_CommandLine_RetainSpaces.patch;revision:1259587049;.

------------------------------------------------------------------------

[2009-11-30 13:16:55] rquadling

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"
}

------------------------------------------------------------------------

Search Discussions

  • Izi at Nov 30, 2009 at 4:04 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=16848&edit=1

    ID: 16848
    Updated by: izi@php.net
    Reported By: RQuadling at GMail dot com
    Summary: Trailing spaces in quoted argument are truncated.
    -Status: Open
    +Status: Closed
    Type: Bug
    Package: Console_CommandLine
    Operating System: Windows XP SP3
    Package Version: 1.1.1
    PHP Version: 5.3.1
    -Assigned To:
    +Assigned To: izi
    Roadmap Versions:
    New Comment:

    -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.




    Previous Comments:
    ------------------------------------------------------------------------

    [2009-11-30 14:10:39] izi

    Makes sense, and I don't think it breaks backward compatibility.
    I'll apply your patch, thanks.

    ------------------------------------------------------------------------

    [2009-11-30 13:17:29] rquadling

    Added #patch
    bug:16848;patch:Console_CommandLine_RetainSpaces.patch;revision:1259587049;.

    ------------------------------------------------------------------------

    [2009-11-30 13:16:55] rquadling

    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"
    }

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedNov 30, '09 at 1:10p
activeNov 30, '09 at 4:04p
posts2
users1
websitepear.php.net

1 user in discussion

Izi: 2 posts

People

Translate

site design / logo © 2022 Grokbase