Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: bug-bash@trodman.com Newsgroups: gnu.bash.bug Subject: bash 1-liner or function to tee to STDERR in middle of pipe? Date: Fri, 03 Jul 2020 09:32:18 -0500 Lines: 44 Approved: bug-bash@gnu.org Message-ID: References: <202007031432.063EWIhD3254754@epjdn.zq3q.org> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: usenet.stanford.edu 1593786754 26921 209.51.188.17 (3 Jul 2020 14:32:34 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trodman.com; s=myselector; t=1593786741; bh=MiPnXDMWP6cRpOU8bOzjBPyQ5o4VluVjLljbHO03uRw=; h=From:To:Subject:Date; b=WyFf3zFo9QMhmbxrvNa72eVByrI2XelvAOidJ80mb9amC2coelkanPnFoGBCM2lPy f4YoKdykYBPuAuQsa2rYXQebqQ9bUUBuOedse6u5zKsVS4PrUjBRqZ7RQx5mvUDv2v CJRbt+nJKQ2XIT1zjkaYMMawCJW6tUY/oVtUgjGA= Content-ID: <3254748.1593786738.1@epjdn.zq3q.org> Received-SPF: pass client-ip=71.19.154.70; envelope-from=bug-bash@trodman.com; helo=xklwu.xen.prgmr.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/03 10:32:22 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <202007031432.063EWIhD3254754@epjdn.zq3q.org> Xref: csiph.com gnu.bash.bug:16527 This does what I want: --8<---------------cut here---------------start------------->8--- _tee_stderr () { <<'____eohd' SYNOPSIS ourname DESCRIPTION Use in a pipe. Leaks STDIN to STDERR. Passes STDIN to STDOUT unchanged. EXAMPLE $ seq 5 |_tee_stderr |tail -2 > /tmp/bar ; echo;cat /tmp/bar 1 2 3 4 5 4 5 ____eohd ( tmpf=$( mktemp ~/tmp/$FUNCNAME.XXX ); cat > $tmpf; cat $tmpf 1>&2; cat $tmpf; rm -f $tmpf ); return; } --8<---------------cut here---------------end--------------->8--- What is better/cleaner? -- thanks!