Handle space after "-x" option.
authorChristian Weiske <cweiske@cweiske.de>
Thu, 1 Feb 2018 10:12:31 +0000 (11:12 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Thu, 1 Feb 2018 10:12:31 +0000 (11:12 +0100)
Normally you do "-xfoo=bar", but some people try to do "-x foo=bar"
which caused strange issues.

Resolves: https://github.com/cweiske/shpub/issues/11

src/shpub/Command/AbstractProps.php

index e186819f49b26a907660a50854f87c028f9ee06f..c893eef3dbdbac8eb9930cf70cb0dc3ea6b02ce8 100644 (file)
@@ -188,6 +188,10 @@ class Command_AbstractProps
         if (count($cmdRes->options['x'])) {
             $postParams = [];
             foreach ($cmdRes->options['x'] as $xproperty) {
         if (count($cmdRes->options['x'])) {
             $postParams = [];
             foreach ($cmdRes->options['x'] as $xproperty) {
+                if ($xproperty == '') {
+                    //happens with "-x foo=bar" instead of "-xfoo=bar"
+                    continue;
+                }
                 list($propkey, $propval) = explode('=', $xproperty, 2);
                 if (!isset($postParams[$propkey])) {
                     $postParams[$propkey] = [];
                 list($propkey, $propval) = explode('=', $xproperty, 2);
                 if (!isset($postParams[$propkey])) {
                     $postParams[$propkey] = [];