Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: =?UTF-8?B?T8SfdXo=?= Newsgroups: gnu.bash.bug Subject: Re: 'foo > >(bar)' doesn't set $! for external foo not invoked via 'command' Date: Mon, 20 Jul 2020 13:52:29 +0300 Lines: 56 Approved: bug-bash@gnu.org Message-ID: References: <20200719204836.GA1184@mutt> <20200720102136.GA1147@mutt> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: usenet.stanford.edu 1595242356 25583 209.51.188.17 (20 Jul 2020 10:52:36 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: rustybird@net-c.com Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=06V/5rJQQZUuiF6QTY1LXEbm45CARmJXegHrhic1XOM=; b=fY6EbRYute7G/+BUyYnk4uh/woZZ8E7WhVF9+skb3/aNpVaceWnU19jAJ8hZocosrI dIl8ei4L+pkPGFFASIQBxB4pEVX2eYyqJzUxxTt7AqXjld5M/9V70TKFVLW5rGOlwDmM f/p4UV89u0PrnX9hzDN13iOf3u7p3axSVPhFsk2Ufkx2wJW8lJhYhiPeDp0Rp+vhHCO9 Zw4ujvyoNS3GbtIG/YIlF6jRtcl5w7ZTe1EMwxaMTecxOGanAljfWCkLG3rv8E96e1Iy Pdn8Txk1z/mRBkJZIhMktrOaZAOP3TkzICgBHRVWvqx1luYOaxTSneO6d0DroC4GTzGv evMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=06V/5rJQQZUuiF6QTY1LXEbm45CARmJXegHrhic1XOM=; b=YFQJvARvsZs0rBJUAX03U8DrrlMNfdW+pzX4NO8DQyl+TKq/JT2PpUAF7Kqr3LvB4y Gm2N7hJ5EIUBD2KzKsOVeY5gyVc9S9kuIriZM6uThW8mh/whyLLeoCa230GiGZCSMwdf +IOAth/oySvVJuWzcbXyh4aJV6lwWtXATcSC12bLt+inrPpX3oUDeSyZy+GMwBz6/qhp 5jp2i086Z9ngV0C2Yhjxb6nPcWsbIP/C0KoOEpHyFo+z/cxphVdxdC5SQvPDAnDS6ptU UiWVmXMmWn/EfW2Z2GcF7bBCl77eeNS5uXfVpfrCR3izFb3j7ksNcionq5tj3SWH+gqc bT1g== X-Gm-Message-State: AOAM533sErBWGPTlifOYo03L9H+rurZqF4jDQVcq6VaYDhkRjcrKZL+I Y1JbWMZ/pCUsME/h3EPInCfr7Vsd6FyRjz3Mz/yc2Ca+ X-Google-Smtp-Source: ABdhPJzaRvAGl/YIlZ6u8mj5LzuTBLEHa4WTl9ouDyXz7FH5OE/hyTP2+Kvp+8N3S6XyD3Y7zdtd/TLXbvxzixAtHS8= X-Received: by 2002:a0c:e5cc:: with SMTP id u12mr20933304qvm.54.1595242349536; Mon, 20 Jul 2020 03:52:29 -0700 (PDT) In-Reply-To: <20200720102136.GA1147@mutt> Received-SPF: pass client-ip=2607:f8b0:4864:20::f2b; envelope-from=oguzismailuysal@gmail.com; helo=mail-qv1-xf2b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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: X-Mailman-Original-References: <20200719204836.GA1184@mutt> <20200720102136.GA1147@mutt> Xref: csiph.com gnu.bash.bug:16589 20 Temmuz 2020 Pazartesi tarihinde Rusty Bird yazd=C4= =B1: > O=C4=9Fuz: > > > 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 > > Yes, I thought stdout_filter and stderr_filter didn't produce output, silly me. `>&"$out" is very ugly though, it'd be nice if `{var}' thing worked at the RHS of redirection operator, like `>&{var}`, which, on bash 5.0.11, ignores `&' -another bug?- and redirects stdout to a file named `{var}'. > 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 > --=20 O=C4=9Fuz