2 ms·
> If stdout is not an interactive terminal, don’t display any animations. This will stop progress bars turning into Christmas trees in CI log output Never disp
by OJFord 3y ago
> If stdout is not an interactive terminal, don’t display any animations. This will stop progress bars turning into Christmas trees in CI log output
Never display animations in stdout! I quite liked TFA in general, but I was skimming around looking for where they were going to advise on the difference between stderr & stdout until I saw that and realised they weren't.
stderr should be all (not just 'errors') of your logging, informational type stuff, the bits that maybe you might animate (and some people will hate) if tty, etc.
stdout should be the useful output - which you may or may not have - regardless of whether tty or not, primarily because an inconsistency like that is just confusing.
e.g.
echo foo | mysed 's/oo/aa/' | cat
# mysed should:
# stdout: faa
# stderr: mysed version 1 here hello\nfound oo\nprinting aa (or whatever)
I don't want to have to fight your tool with grep to get the 'actual' output lines. And I don't want to struggle to debug it because if I remove `| cat` above (as a silly example) it behaves differently than with it.
- samatman 3y agoThat's a good rule, pity about the name. If we could go back in time and make it stdin, stdout, and stdext (because UNIX so six letters, but standard_extra, or standard_extended), we might have a prayer of getting people to follow that convention. But it's called stderr, so devs think, quite reasonably, that it should be used for error reporting, and conversely, if it isn't an error, it goes in stdout. But I agree with you that this is the better way to structure a program. You might confuse more people with it, but they'll be able to do more useful things with its output, so that's a win.
- OJFord 3y agoI think if I could go back in time, my fix would be to make stderr the default. i.e. everything written 'out' goes to stderr until you explicitly write it as an output to stdout (or another descriptor/file), the inverse of the current situation. (Ok, sure, I'd probably change the name too!)
- nerdponx 3y agoPowershell has something like 5 or 6 different output streams.
- OJFord 3y agoUnix doesn't really have a limit that I know of, certainly not a low one, stdin/out/err are just names for the (very) common descriptors numbered 0/1/2 respectively; you can use another. (In fact it's sometimes helpful in scripting for dealing with exactly this issue of potentially badly behaved subprocesses.)
- eikenberry 3y ago> stdout should be the useful output To add a small tweak to this rule... "stdout should be what you ask for". If I ask for --help, that should go to stdout. If I ask for logs, they should go to stdout. If I don't ask for it, stderr.
- OJFord 3y agoYup, absolutely, that is what I meant - the useful output from the command, the thing you were looking for, that it's actually doing/retrieving.
- nmz 3y agoSo where do you display animations then? I'd also say that coloring is not information.