30 January 2024

stdout is only for a program's main output

  • Not for any other information
  • Not for progress bars
  • Not for warnings
  • Not for errors

Only for the main output.

Why does this matter?

It will screw up pipelines, scripts, and other programs that try and use your program.

For example, I recently used an SQL formatter that dumped warnings in the middle of the file I was formatting. Very annoying.

But isn't stderr only for errors?

Nope, this is a common misconception - stderr (which JavaScript's console.error() function prints to) is for any output other than the main program result, this includes progress bars, debug info, warnings, and errors.

Tags: Shell Unix Tech