Skip to content

Bug:  #3255

Description

@salalex

Describe the bug
In custom CLI commands, parameters containing dashes ('-') break the parsing of the command line.

CodeIgniter 4 version
CI 4.0.3

Affected module(s)
I suppose the problem is in CodeIgniter\CLI\BaseCommand.

Expected behavior, and steps to reproduce if appropriate
When running a custom command with some parameters, I expect to find the value of all parameters in $params array, but if one parameter value contains dashes, that parameter and the all following ones are missing in the array.

To reproduce, simply create a custom command:

<?php namespace App\Commands;

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;

class TestCmd extends BaseCommand
{
    protected $group        = "Test";
    protected $name         = "test:param";
    protected $usage        = "test:param param1 param2 param3 param4 ";

    public function run(array $params)
    {
        CLI::write(print_r($params, true));
    }

}

and run it with some parameters containing dashes:

spark test:param p1 p2-a p3 p4

Expected result:

Array
(
    [0] => p1
    [1] => p2-a
    [2] => p3
    [3] => p4
)

Actual result:

Array
(
    [0] => p1
)

Context

  • OS: Centos 8 Linux
  • Web server: Apache 2.4.37
  • PHP version: 7.2.24

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions