Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16588
| From | Rusty Bird <rustybird@net-c.com> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: 'foo > >(bar)' doesn't set $! for external foo not invoked via 'command' |
| Date | 2020-07-20 10:21 +0000 |
| Message-ID | <mailman.207.1595240508.24492.bug-bash@gnu.org> (permalink) |
| References | <20200719204836.GA1184@mutt> <CAH7i3Lqre0SoX_nJaMis=g7T_+X1LtrsPWJiJCjRCrHT1Y4_Jw@mail.gmail.com> <20200720102136.GA1147@mutt> |
[Multipart message — attachments visible in raw view] - view raw
Oğuz:
> > For context - I'm filtering a program's stdout and stderr
> > (separately), requiring successful exit statuses for the program and
> > both filters:
> >
> > set -u -o pipefail
> > { program 2> >(stderr_filter >&2) && wait $!; } | stdout_filter &&
> > ...
> Not sure if process substitution is really necessary here,
>
> set -u -o pipefail
> { program 2>&3 | stdout_filter; } 3>&1 | stderr_filter && ...
>
> does the same thing.
That one filters program's stdout twice - first through stdout_filter
and then through stderr_filter - with program's stdout and stderr both
finally arriving at stdout. But tweaked like this, it seems to cover
all the bases:
set -u -o pipefail
{
program 2>&1 >&"$out" {out}>&- |
stderr_filter >&2 {out}>&-
} {out}>&1 | stdout_filter
And it even waits for stderr_filter if program failed. My original
snippet neglected that case, otherwise it would have looked more like
set -u -o pipefail
(
trap 'wait $! || exit $?' EXIT
command program 2> >(stderr_filter >&2)
) | stdout_filter
which isn't exactly pretty either, even if the bug(?) requiring
'command' is fixed.
Rusty
Back to gnu.bash.bug | Previous | Next | Find similar
Re: 'foo > >(bar)' doesn't set $! for external foo not invoked via 'command' Rusty Bird <rustybird@net-c.com> - 2020-07-20 10:21 +0000
csiph-web