Skip to content

Commit 6450b61

Browse files
If a Drush command returns a string value, then print it, even if the command does not define an outputformat record in its command definition.
1 parent a65f369 commit 6450b61

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

includes/command.inc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,16 +458,19 @@ function drush_handle_command_output($command, $structured_output) {
458458
// Only handle output here if the command defined an output format
459459
// engine. If no engine was declared, then we presume that the command
460460
// handled its own output.
461-
if ((!empty($structured_output) || ($structured_output === 0)) && !empty($command['engines']['outputformat'])) {
461+
if ((!empty($structured_output) || ($structured_output === 0))) {
462462
// If the command specifies a default pipe format and
463463
// returned a result, then output the formatted output when
464464
// in --pipe mode.
465465
$formatter = drush_get_outputformat();
466+
if (!$formatter && is_string($structured_output)) {
467+
$formatter = drush_load_engine('outputformat', 'string');
468+
}
466469
if ($formatter) {
467470
if ($formatter === TRUE) {
468471
return drush_set_error(dt('No outputformat class defined for !format', array('!format' => $format)));
469472
}
470-
if (!in_array($formatter->selected_engine, $command['engines']['outputformat']['usable'])) {
473+
if ((!empty($command['engines']['outputformat'])) && (!in_array($formatter->selected_engine, $command['engines']['outputformat']['usable']))) {
471474
return $formatter->format_error(dt("The command '!command' does not produce output in a structure usable by this output format.", array('!command' => $command['command'])));
472475
}
473476
// Add any user-specified options to the metadata passed to the formatter.

0 commit comments

Comments
 (0)