_drush_backend_generate_command() redirects STDERR to STDOUT when calling the remote drush command over ssh. This has the undesirable effect of making it almost impossible to parse the returned output from a script.

In particular, I'm making use of the --pipe switch on the user commands, but I find myself having to do all sorts of cleanup on the output before I can parse the comma separated string. Using the -q switch helps a little, but I have been caught a couple of times by failed writes to the cache file and other things that while helpful to know about, don't belong in the output.

I suggest an alias option to be able to suppress STDERR altogether, or maybe an option to specify a location to write STDERR to. This way, one could specify /dev/null or an actual log file.

Comments

greg.1.anderson’s picture

Priority: Normal » Major

Yes, Drush's handling of stderr does cause some problems. It should be improved at some point, but it is a more difficult job than simply adding a flag to redirect it, as the handling of i/o streams in backend invoke is closely coupled with the logging mechanism, etc.

c.f. #1719436: Not all commands using an @alias working?

greg.1.anderson’s picture

Title: Option to suppress STDERR rather than redirect it to STDOUT » Improve Drush's handling of STDERR in backend invoke
anarcat’s picture

Version: » 7.x-5.x-dev
Status: Active » Closed (duplicate)
greg.1.anderson’s picture