Redirection and subshells and file position pointer
From:
Stan Marsh
Subject:
Redirection and subshells and file position pointer
Date:
Wed, 09 Jul 2025 11:53:40 -0600
I see. FWIW, using -a seems
kludgey/ugly/error-prone-in-as-yet-undetermined-ways.
I've never liked the "tee -a" construct.
Using -a is basically conceding that you can't solve the problem (which does
indeed
seem to be the case), so you're just going to kludge around it. And, as
implied in
the OP, there are plenty of workarounds/kludges available; we don't need any
more (!)
What would really be nice is a say to make the sh/bash "$()" construct capture
some
other fd - other than 1 (say, 3, in the example below). I have a vague memory
of
there being a way to do this (in some shell, probably not bash), but obviously,
the
details escape me at the moment. Then you could simply do:
... $(file ... | tee /dev/fd/3) ...
And so it goes...
=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.
Note that they always end up in my Spam file anyway, so it is annoying to have
to
periodically clean that out.