TYPO3 Flow Base DistributionPackagesApplications

Bug #48135

funtion prepareCommand() in class ShellCommandService

Added by Dietrich Heise about 2 years ago. Updated almost 2 years ago.

Status:Resolved Start date:2013-05-13
Priority:Must have Due date:
Assigned To:Dietrich Heise % Done:

100%

Category:-
Target version:-

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
}

Associated revisions

Revision f543edc4
Added by Dietrich Heise almost 2 years ago

[BUGFIX] Return code of multiple shell commands

Additionally adds a unit test for shell process execution and refactors
some duplicate code.

Resolves: #48135
Change-Id: I15bf9cb51bfeea40d618cce860886c5cae2cba51

History

#1 Updated by Dietrich Heise about 2 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 about 2 years ago

  • Status changed from New to Needs Feedback
  • Assigned To set to Dietrich Heise

Could you please make a change in gerrit for this?

#3 Updated by Gerrit Code Review about 2 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 almost 2 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 almost 2 years ago

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

Also available in: Atom PDF