coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tee: Add -q, --quiet option to not write to stdout


From: Alejandro Colomar (man-pages)
Subject: Re: [PATCH] tee: Add -q, --quiet option to not write to stdout
Date: Thu, 21 Jan 2021 19:00:31 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1

Hi Berny,

On 1/21/21 6:17 PM, Bernhard Voelker wrote:
> On 1/21/21 4:48 PM, Alejandro Colomar (man-pages) wrote:
>> - cat, as Padraig pointer out doesn't have an option to append.
>> - dd doesn't either (AFAIK).
> 
> yes, it has:
> 
>   dd oflag=append conv=notrunc of=SOMEFILE

Do-h! That's right.

> 
>> - dd is quite dangerous, and I would avoid it for simple tasks.
> 
> well, every tool which can overwrite something could be considered
> dangerous then, right? ;-)

Well, it is, but dd is happy overwriting /dev/sda :)

> 
>> - I read on stackexchange (I couldn't find the thread now)
>>    that the dd performance was lower, but I don't remember well.
> 
> well, maybe you'd want to play with a larger blocksize?
>   dd ... bs=1m iflag=fullblock

I have to say that performance is my least concern here.
Moreover, dd is very versatile due to the many flags you can specify,
with which you can tune performance for your specific needs if you need.

However, I'd say the 1st concern here, for me at least, and I believe
for many others, is consistency and simplicity.

dd has been designed to write to files,
but it is a much more powerful tool,
which is not as simple to use as common filters.
It has a very different syntax,
which for wiping or copying disks is very powerful,
but for using dd in pipelines for common tasks
makes it a bit uncomfortable.

cat has been designed to concatenate files.
Historically it has also been used for reading,
because it's a quite generic tool,
and people like generic tools that can be used in many contexts.

If you could somehow 'sudo >',
that would make it.

tee has been designed with something in mind:
reading lines from stdin and writing them to files.
For me it seems to be the exact thing we're talking about.
Having also stdout makes it also useful for
debugging/reading intermediate values in a pipeline:
| tee /dev/tty |
but that doesn't disqualify it to simply write to files.

Why should tee be the tool to write the contents of a pipeline
in the middle of that pipeline,
but not in the end of it?

Yes, the > redirector is the 'tool for the job',
but their designers didn't have sudo back then (did they?),
so it simply doesn't work.

So, consistency and simplicity is my main concern:

Code should be short and to the point;  easy to read, simple,
so that you can see at first glance what it does.
When I see dd, the first thing that comes to me is wiping a disk.
Also, its options aren't something that one is usually familiar with.
And with cat, you need a quite complex structure just to do one thing;
it's easy to make a mistake there, and not so easy to read.

tee -q file

is simple, is readable, nobody can doubt what it does
(okay, -q is a new option,
so you would have to read the man the first time,
but that's all).
Yes, there are many ways to write the same thing.
But none of them is simpler, or easier to write/read.



On 1/21/21 6:41 PM, Jeffrey Walton wrote:
> If you accept --quiet, then you are supposed to accept --silent, too.
> Also see https://www.gnu.org/prep/standards/html_node/Option-Table.html.
>

Fair enough!  I'll add that.


Thanks,

Alex



reply via email to

[Prev in Thread] Current Thread [Next in Thread]