From owner-freebsd-hackers@freebsd.org Tue Jan 26 13:59:15 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BBC524EF11B for ; Tue, 26 Jan 2021 13:59:15 +0000 (UTC) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DQ7dH2Rlvz3svl; Tue, 26 Jan 2021 13:59:15 +0000 (UTC) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 10QDvssr095194; Tue, 26 Jan 2021 05:57:54 -0800 (PST) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: (from freebsd-rwg@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 10QDvrJL095193; Tue, 26 Jan 2021 05:57:53 -0800 (PST) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <202101261357.10QDvrJL095193@gndrsh.dnsmgr.net> Subject: Re: [PATCH v3 (resend)] tee: Add -q, --quiet, --silent option to not write to stdout In-Reply-To: <834af55b-0935-ec2f-784c-3874cd05ba75@gmail.com> To: "Alejandro Colomar (man-pages)" Date: Tue, 26 Jan 2021 05:57:53 -0800 (PST) CC: Bernhard Voelker , Coreutils , Fabrice BAUZAC , Otto Moerbeek , Alex Henrie , juli@clockworksquid.com, Jeffrey Walton , freebsd-hackers@freebsd.org, William Ahern , Roman Czyborra , oshogbo@freebsd.org, tech@openbsd.org, Christian Groessler , linux-api@vger.kernel.org, Michael Kerrisk , ed@nuxi.nl, Eric Pruitt X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 4DQ7dH2Rlvz3svl X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; TAGGED_RCPT(0.00)[]; REPLY(-4.00)[] X-Mailman-Approved-At: Tue, 26 Jan 2021 18:11:26 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2021 13:59:15 -0000 > 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.) Its name is cat(1) cat /dev/fd/# >outputfile > > 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 > > Reviewed-by: Alejandro Colomar > > > > 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/ > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > -- Rod Grimes rgrimes@freebsd.org