diskus icon indicating copy to clipboard operation
diskus copied to clipboard

Undocumented stdout behaviour

Open Kresimir235 opened this issue 4 years ago • 1 comments

Printed output on the screen does not match the output sent to stdout. For example:

$ diskus
23.24 MB (23,240,704 bytes)
$ diskus | cat
23240704

Now, I try to understand the purpose of this: when piping to an external program it is often useful to have the raw number, without any formatting. That's all well and good, but it is unexpected as it does not comply with conventions used by other CLI tools. Also, there is no mention of it in the documentation. Additionally, there should be a simple way to send the entire, formatted output to stdout. Typically, unless the output is dynamic (like text progress bars), what one sees on the screen should be the stdout, and if there is a need for changing the format of the output, that should be handled by the command options.

Kresimir235 avatar Feb 07 '21 07:02 Kresimir235

Now, I try to understand the purpose of this: when piping to an external program it is often useful to have the raw number, without any formatting. That's all well and good, but it is unexpected as it does not comply with conventions used by other CLI tools.

I think there are a few examples where programs do something similar. ls changes its default format from a space-saving format to a line-oriented one:

▶ ls
bar  baz  foo

▶ ls | cat            
bar
baz
foo

ripgrep also does something similar and changes its output format to something that is more suited for pipeline usage.

Also, there is no mention of it in the documentation.

Agreed, that should be fixed.

Additionally, there should be a simple way to send the entire, formatted output to stdout.

Also agreed.

sharkdp avatar Feb 07 '21 21:02 sharkdp