linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>
To: Bernhard Voelker <mail@bernhard-voelker.de>,
	Coreutils <coreutils@gnu.org>
Cc: Fabrice BAUZAC <noon@mykolab.com>, Otto Moerbeek <otto@drijf.net>,
	Alex Henrie <alexhenrie24@gmail.com>,
	juli@clockworksquid.com, Jeffrey Walton <noloader@gmail.com>,
	freebsd-hackers@freebsd.org,
	William Ahern <william@25thandclement.com>,
	Roman Czyborra <roman@czyborra.com>,
	oshogbo@freebsd.org, tech@openbsd.org,
	Christian Groessler <chris@groessler.org>,
	linux-api@vger.kernel.org,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	ed@nuxi.nl, Eric Pruitt <eric.pruitt@gmail.com>
Subject: Re: [PATCH v3 (resend)] tee: Add -q, --quiet, --silent option to not write to stdout
Date: Tue, 26 Jan 2021 10:08:24 +0100	[thread overview]
Message-ID: <834af55b-0935-ec2f-784c-3874cd05ba75@gmail.com> (raw)
In-Reply-To: <d0d1697b-7851-9078-289e-02ef76f3303a@gmail.com>

Hi Berny,

On 1/25/21 12:33 PM, Alejandro Colomar (man-pages) wrote:
> On 1/25/21 5:03 AM, Bernhard Voelker wrote:
>> On 1/24/21 9:01 PM, Alex Henrie wrote:
>>> I am definitely interested. Bernhard Voelker seemed to express
>>> interest as well, conditional on -q being added to POSIX first.[1]
>>
>> Just to clarify: I'm not as enthusiastic to add that option as it
>> may have sounded.
>>
>> Let me put it like this: if -q once gets standardized by POSIX,
>> then we'd take it over in the GNU tee implementation.
>>
>> Let me summarize so far:
>> The suggestion is to solve the problem to save some data coming from
>> a pipe as a different user.
>> There are at least those known solutions:
>>    - use > or >> redirection.
>>    - use dd(1)
>>
>> I have the impression that a home for this feature was searched
>> in any tool, and as tee(1) already knew how to write to a file,
>> had the "append" feature, and is often used in pipes, it was
>> tempting to add it there.
>>
>> But looking deeper, --quiet doesn't seem to fit well into 'tee'.
>> It even contradicts to the title line in the man page:
>>    "read from standard input and write to standard output and files"
>>
>> An off-tech argument: ask a local plumber if he'd would ever use
>> a tee piece instead of a pipe end piece.  I guess he would only
>> if he wouldn't have anything else at hand.
> 
> I never knew what 'tee' meant.  That makes sense now.
> 
>>
>> A word to the proposed patch: what should happen, if the user does
>> not give a file?
>>    A | B | tee -q
>> The patch just silently ignored that situation which feels wrong.
>>
>> Therefore, adding a feature which does not really fit is wrong, and
>> contradicts the one-tool-for-one-purpose UNIX philosophy.
>>
> 
> Agreed.
> 
>> OTOH I understand that there's a little gap in the tool landscape.
>> Astonishingly, there doesn't seem to exist a trivial tool to redirect
>> from standard input (or any other input file descriptor) to a file.
>> I wrote such a little tool in the attached:
>>
>>    $ src/sink --help
>>    Usage: src/sink [OPTION]... FILE
>>    Copy input stream to FILE.
>>
>>    Mandatory arguments to long options are mandatory for short options 
>> too.
>>
>>      -a, --append              append to the given FILE, do not overwrite
>>      -c, --create              ensure to create FILE, error if exists
>>      -i, --input-stream=FD     read from stream FD instead of standard 
>> input


On second thought, this program does two things: read any FD, and write 
to file.  I think it should be limited to writing to a file from stdin.

If you think there's a need for reading FDs other than 0, you might as 
well want to pipe that information you're reading from them to filter it 
with another tool, and this program doesn't allow you to do that, as 
it's a sink.

So, I would remove '-i, --input-stream'.  (And if you think it's 
missing, maybe write a program to read from any FD and write to stdout.)

Regards,

Alex


>>
>>    The default input stream number FD is 0, representing the standard 
>> input.
>>
>> This allows not only to copy data from standard input, but from any
>> file descriptor open for reading.  It also allows control over
>> how the output file will be opened (e.g. with O_CREAT|E_EXCL).
>>
>> The OPs case would look like:
>>
>>    echo 'foo' | sudo sink /etc/foo
>> or
>>    echo 'foo' | sudo sink -a /etc/foo  # append.
>> or
>>    echo 'foo' | sudo sink -c /etc/foo  # ensure creation of the file.
>>
>> I'm not sure if this will ever be considered for inclusion -
>> I just did it "for fun". ;-)
> 
> Tested-by: Alejandro Colomar <alx.manpages@gmail.com>
> Reviewed-by: Alejandro Colomar <alx.manpages@gmail.com>
> 
> Much better than my patch.  :-)
> 
>>
>> Have a nice day,
>> Berny
>>
> 
> Have a nice day!
> Alex
> 
> 
> -- 
> Alejandro Colomar
> Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
> http://www.alejandro-colomar.es/


-- 
--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

  reply	other threads:[~2021-01-26 18:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210121131735.317701-1-alx.manpages@gmail.com>
     [not found] ` <8aa1d0b4-d2ec-7d18-120b-cae59708767c@draigBrady.com>
     [not found]   ` <424b9fb9-c740-1a2f-bd79-0b4035104698@gmail.com>
     [not found]     ` <e1a3b389-b808-92db-258d-85b60748b4dc@bernhard-voelker.de>
     [not found]       ` <06fb3df3-a956-3ec1-eadb-82fd89ec62d5@gmail.com>
     [not found]         ` <af2fb24a-a03a-35ef-c86e-545844b61a8d@groessler.org>
     [not found]           ` <CAMMLpeRSh5HKi=sJV7y=pav26EzzP-yEe0+Dgp_=mtBUhtFvaQ@mail.gmail.com>
     [not found]             ` <3bb6a134-c477-116c-182d-d6e24dc342e0@bernhard-voelker.de>
     [not found]               ` <f78ec1a9-f07f-de20-26cc-4be254e3e921@gmail.com>
2021-01-21 22:49                 ` [PATCH] tee: Add -q, --quiet option to not write to stdout Alejandro Colomar (man-pages)
2021-01-21 23:12                   ` [PATCH v2] tee: Add -q, --quiet, --silent " Alejandro Colomar
2021-01-22 18:25                     ` Alejandro Colomar (man-pages)
2021-01-23 14:53                   ` [PATCH] " Alejandro Colomar
2021-01-24 12:18                   ` [PATCH v3 (resend)] " Alejandro Colomar
2021-01-24 16:11                     ` Teran McKinney
2021-01-24 16:22                       ` Alejandro Colomar (man-pages)
2021-01-24 17:51                     ` Otto Moerbeek
2021-01-24 17:58                       ` Theo de Raadt
2021-01-24 20:01                       ` Alex Henrie
2021-01-24 20:22                         ` Otto Moerbeek
2021-01-25  4:03                         ` Bernhard Voelker
2021-01-25 11:33                           ` Alejandro Colomar (man-pages)
2021-01-26  9:08                             ` Alejandro Colomar (man-pages) [this message]
2021-01-27  1:40                           ` Alex Henrie
2021-03-14  9:44                           ` Alejandro Colomar (man-pages)
2021-03-15 17:42                             ` Alex Henrie
2021-03-15 20:20                               ` Alex Henrie
2021-01-25 16:06                     ` Philipp-Joachim Ost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=834af55b-0935-ec2f-784c-3874cd05ba75@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=alexhenrie24@gmail.com \
    --cc=chris@groessler.org \
    --cc=coreutils@gnu.org \
    --cc=ed@nuxi.nl \
    --cc=eric.pruitt@gmail.com \
    --cc=freebsd-hackers@freebsd.org \
    --cc=juli@clockworksquid.com \
    --cc=linux-api@vger.kernel.org \
    --cc=mail@bernhard-voelker.de \
    --cc=mtk.manpages@gmail.com \
    --cc=noloader@gmail.com \
    --cc=noon@mykolab.com \
    --cc=oshogbo@freebsd.org \
    --cc=otto@drijf.net \
    --cc=roman@czyborra.com \
    --cc=tech@openbsd.org \
    --cc=william@25thandclement.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).