We add an extra newline at the end of pipe'd output, which seems fine, but then we pass it to drush_print_r which adds another newline.

#1659668: variable-get outputs in single line when using --pipe introduced a test failure because we do an assertEmpty on a --pipe'd output that should be empty, but it fails because it's \n instead of empty.

This also creates what I consider a bug when you do something like:

drush pml --status=enabled --pipe|wc -l

That'll tell you you have one more module enabled than your actually do.

I think the best fix is to give drush_print_r the same newline option as drush_print, and set it to false when we print piped output.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Looks reasonable to me.

greg.1.anderson’s picture

I don't think that the patch is quite right. I think you meant this instead:

 function drush_print_r($array, $handle = NULL, $newline = TRUE) {
  drush_print(print_r($array, TRUE), 0, $handle, $newline);
 }

Untested.

msonnabaum’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
964 bytes

Oops. Uploaded the wrong patch.

greg.1.anderson’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

msonnabaum’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.