Bug #48135

funtion prepareCommand() in class ShellCommandService

Added by Dietrich Heise over 8 years ago. Updated over 8 years ago.

Status:
Resolved
Priority:
Must have
Target version:
-
Start date:
2013-05-13
Due date:
% Done:

100%

Estimated time:

Description

If the command-array is imploded by a semicolon
only the return code of the last command is used for the exit code.

Example: a TYPO3.Surf TASK - execute function:

$commands = array(
"/bin/false",
"ls la"
);
$this
>shell->executeOrSimulate($commands, $node, $deployment);

This example will have an exit code of zero!

For this example it is better to implode the commands by "&&", so if one command fail, no other command will be executed and the exit code ist right.

--- a/Classes/TYPO3/Surf/Domain/Service/ShellCommandService.php
++ b/Classes/TYPO3/Surf/Domain/Service/ShellCommandService.php
@ -188,7 +188,7 @ class ShellCommandService {
if (is_string($command)) {
return trim($command);
} elseif (is_array($command)) {
- return implode(';', $command);
return implode('&&', $command);
} else {
throw new \TYPO3\Surf\Exception\TaskExecutionException('Command must be string or array, ' . gettype($command) . ' given.', 1312454
}

#1

Updated by Dietrich Heise over 8 years ago

$commands = array(
  "/bin/false",
  "ls -la" 
);
$this->shell->executeOrSimulate($commands, $node, $deployment);
--- a/Classes/TYPO3/Surf/Domain/Service/ShellCommandService.php
+++ b/Classes/TYPO3/Surf/Domain/Service/ShellCommandService.php
@@ -188,7 +188,7 @@ class ShellCommandService {
                if (is_string($command)) {
                        return trim($command);
                } elseif (is_array($command)) {
-                       return implode(';', $command);
+                       return implode('&&', $command);
                } else {
                        throw new \TYPO3\Surf\Exception\TaskExecutionException('Command must be string or array, ' . gettype($command) . ' given.', 1312454
                 }
#2

Updated by Tobias Liebig over 8 years ago

  • Status changed from New to Needs Feedback
  • Assignee set to Dietrich Heise

Could you please make a change in gerrit for this?

#3

Updated by Gerrit Code Review over 8 years ago

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22776

#5

Updated by Gerrit Code Review over 8 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22776

#6

Updated by Dietrich Heise over 8 years ago

  • Status changed from Needs Feedback to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF