From owner-freebsd-hackers@freebsd.org Mon Mar 15 20:20:55 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 38A3F5AE336 for ; Mon, 15 Mar 2021 20:20:55 +0000 (UTC) (envelope-from alexhenrie24@gmail.com) Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DznqV2xp9z3tHk; Mon, 15 Mar 2021 20:20:54 +0000 (UTC) (envelope-from alexhenrie24@gmail.com) Received: by mail-lf1-x12c.google.com with SMTP id v2so45875162lft.9; Mon, 15 Mar 2021 13:20:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5o+tdW+BV7Wm+7chs7B/caIMYJ3/SLZxEpYQvO4IUTw=; b=H9/XcVOnqaB+05V4nFAe/DIRo555bUX6rHMiUSrBpeFHqnIxjdztmQn8zbasu1KIfa /sVMt73yWhBLCK5XaOV7eIJAb7DiozjNFHfYwIm0DxTtT8ZL8diy4tNPVVF3UnBT9BbS 0lAbbGXQBGT5u/3lA7rSV8RD2zK5ui6tcA/zhS0I2/s7MMuLaw0Hp1xo6ObEvV5HI5I+ sgt0RoUUlzXr/HGBexmwX9YcnUWVzJDSSfAgFdW8A9SUuzJ1dj0lKR1r4iXObS+FQACX KSTDhDXaJGv0sqHMiwTSDuRmUqifUXPgBHyY5U/12dX8A9xE30xcNYWpF/7tOh+A8RCr szTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5o+tdW+BV7Wm+7chs7B/caIMYJ3/SLZxEpYQvO4IUTw=; b=CnsT39TfxP4wajvFZG4ZMnbqhUr2JIRBg3xRYNL8OStEfey1XSnjyTAQPCnEp3pTRS 2rqpXBtWDkqqE9RTYi+o6/6cAggKUGU0q2RjYo7dc+7ibljCp79f5L/RRlix9pdn7mCo o+hpMl/9N9XL0B6dXj4NCVhrmF8Tssk4C53Injqn4kBRhTFV3a3Y2e1XiP3Pi7y56id9 wEFocMGwRUl3QDcfaYuTQC69AWQcB/XI7J1ACc7DATc96l5pQYUULDqiSpEKQIp8LeuE OLCW9+BhVHDYhVGC2qplpqro3IbUAqUDA7PmdulNiHHmSTVQFow1BHRfueUa74xTtS96 yyWQ== X-Gm-Message-State: AOAM531si8IZUgJSyxl3Dl0O9iOdpXZnBW5WgsQxmRPPAZkRPc2OyAcL yRCg+eM/Y7Egt4Dg9VC3PfE79YYISof/d4YEYJA= X-Google-Smtp-Source: ABdhPJwvGVF19aniHTtSRwoAzpZgDayRD56HV3hWLx5di0gQKHCAoaGF5qNB4u1qHrAUpU3Fe5kmmxzFscM9V9bsgbA= X-Received: by 2002:a19:5213:: with SMTP id m19mr8835236lfb.203.1615839652612; Mon, 15 Mar 2021 13:20:52 -0700 (PDT) MIME-Version: 1.0 References: <1f8ce444-35e2-56a7-dbd1-34e885372b11@gmail.com> <20210124121845.38293-1-alx.manpages@gmail.com> <48228481-c1b0-dcce-8598-4c88aedb2ef9@gmail.com> In-Reply-To: From: Alex Henrie Date: Mon, 15 Mar 2021 14:20:40 -0600 Message-ID: Subject: Re: [PATCH v3 (resend)] tee: Add -q, --quiet, --silent option to not write to stdout To: "Alejandro Colomar (man-pages)" Cc: Bernhard Voelker , Otto Moerbeek , Coreutils , Fabrice BAUZAC , Juli Mallett , 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 Schouten , Eric Pruitt Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4DznqV2xp9z3tHk X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=H9/XcVOn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of alexhenrie24@gmail.com designates 2a00:1450:4864:20::12c as permitted sender) smtp.mailfrom=alexhenrie24@gmail.com X-Spamd-Result: default: False [-2.50 / 15.00]; MAILMAN_DEST(0.00)[freebsd-hackers]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::12c:from]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::12c:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_TWELVE(0.00)[17]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::12c:from]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[]; FREEMAIL_CC(0.00)[bernhard-voelker.de, drijf.net, gnu.org, mykolab.com, clockworksquid.com, gmail.com, freebsd.org, 25thandclement.com, czyborra.com, openbsd.org, groessler.org, vger.kernel.org, nuxi.nl] X-Mailman-Approved-At: Tue, 16 Mar 2021 06:19:11 +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: Mon, 15 Mar 2021 20:20:55 -0000 On Mon, Mar 15, 2021 at 11:42 AM Alex Henrie wrote: > > On Sun, Mar 14, 2021 at 3:44 AM Alejandro Colomar (man-pages) > 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]: > > > > 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 Actually, it looks like `pee` (also from moreutils) can be used for throwing input into the void. So between `sponge` and `pee`, I think all the use cases are covered! -Alex