Output of foreach can't be piped


When running foreach to run a series of commands over an inputted collection, the output of each internal command is sent directly to the console so it's not possible to capture all the output and pipe it somewhere.

The overall reason for this issue is because command output is not streamed directly to the console. That's not getting fixed any time soon, so the workaround for now is two fold.

  1. The command service is already aware of when it's running a command that has its output piped. This is used right now for the "run" command. Set a new environment variable called box_currentCommandPiped that will exist and be true when the current command is in front of a pipe

  2. in foreach, check this flag, and capture the sub command output when it's being piped. The conditional is so non-piped output can still appear right away in the console as a large collection is processed.



Brad Wood


Brad Wood



Affects versions

Fix versions