Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Mar 2021 11:42:36 -0600
From:      Alex Henrie <alexhenrie24@gmail.com>
To:        "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>
Cc:        Bernhard Voelker <mail@bernhard-voelker.de>, Otto Moerbeek <otto@drijf.net>, Coreutils <coreutils@gnu.org>, Fabrice BAUZAC <noon@mykolab.com>,  Juli Mallett <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 Schouten <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
Message-ID:  <CAMMLpeS2qSzoVhsjAih1VpCwGwnCsrVBzwe5D0tqXyA-3d5nTg@mail.gmail.com>
In-Reply-To: <48228481-c1b0-dcce-8598-4c88aedb2ef9@gmail.com>
References:  <1f8ce444-35e2-56a7-dbd1-34e885372b11@gmail.com> <20210124121845.38293-1-alx.manpages@gmail.com> <YA2ztHUATu1gOxoV@clue.drijf.net> <CAMMLpeSLbWtRrrzOjB6DJgZCem8KWpy7_pWmr6ecuGrSmg4Eng@mail.gmail.com> <d0f93c40-c471-7ef7-fa9a-2f467d775d3e@bernhard-voelker.de> <48228481-c1b0-dcce-8598-4c88aedb2ef9@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Mar 14, 2021 at 3:44 AM Alejandro Colomar (man-pages)
<alx.manpages@gmail.com> wrote:
>
> On 1/25/21 5:03 AM, Bernhard Voelker wrote:
> > 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
> >
> >    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". ;-)
> >
> > Have a nice day,
> > Berny
> >
>
> By chance, I just found out that there is a tool very similar to 'sink'
> in moreutils [1].  It's called 'sponge'.
>
> [1]: <https://joeyh.name/code/moreutils/>;
>
> So this feature already exists, and therefore I drop my patches.
>
> Cheers,
>
> Alex

Interesting, thanks for sharing. There's still no `sponge -q` option
though--it always writes either to a file or to standard output.

-Alex



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMMLpeS2qSzoVhsjAih1VpCwGwnCsrVBzwe5D0tqXyA-3d5nTg>