Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Rusty Bird Newsgroups: gnu.bash.bug Subject: 'foo > >(bar)' doesn't set $! for external foo not invoked via 'command' Date: Sun, 19 Jul 2020 20:48:36 +0000 Lines: 77 Approved: bug-bash@gnu.org Message-ID: References: <20200719204836.GA1184@mutt> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ibTvN161/egqYuK8" X-Trace: usenet.stanford.edu 1595192328 17486 209.51.188.17 (19 Jul 2020 20:58:48 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org X-EA-Auth: fv9f9VAJt1zctiIfw8Xlp1IXtvFHjbTa6jbzOHmRpmOBk5dIYgEENfNn3De4cGPVyk4PqrcFBlUruqcd8l+tT5jQE7JRMCrBiZpbEvfTRWs= Mail-Followup-To: bug-bash@gnu.org Content-Disposition: inline Received-SPF: pass client-ip=213.182.54.6; envelope-from=rustybird@net-c.com; helo=relay-1.mailobj.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/19 16:58:41 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: <20200719204836.GA1184@mutt> Xref: csiph.com gnu.bash.bug:16583 --ibTvN161/egqYuK8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-parentheses -Wno-format-security uname output: Linux [...] 4.19.132-1.pvops.qubes.x86_64 #1 SMP Tue Jul 14 03:42:21 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-redhat-linux-gnu Bash Version: 5.0 Patch Level: 17 Release Status: release Description: $! isn't set to the PID of 'bar' for foo > >(bar) if 'foo' is an external program (as opposed to a builtin or function) - unless it's invoked via 'command'. Repeat-By: type date # "date is /usr/bin/date" set -u echo $! # "bash: $!: unbound variable" date > >(sleep 20) echo $! # "bash: $!: unbound variable" command date > >(sleep 21) echo $! # "123" date_wrapper() { date; } date_wrapper > >(sleep 22) echo $! # "234" 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 && ... This only works if 'program' is changed to 'command program'. Rusty --ibTvN161/egqYuK8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEhLWbz8YrEp/hsG0ERp149HqvKt8FAl8UsaRfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDg0 QjU5QkNGQzYyQjEyOUZFMUIwNkQwNDQ2OUQ3OEY0N0FBRjJBREYACgkQRp149Hqv Kt+VIw/8DKt2j2x02R1EbDRrknIM6Oo5NEhhUQTGgul8tPsxyUPnmNSyJ6fKazaj 23CURVxujzhaSoXyr5q3Jq1EJUXoGxhfN32R6noEzNZC/xZKCkxboWM1I7BHUohd qdBCmhv0OEu664h28ETml/rDQ7zK60t9GK9wQNB5iGXWe/8qsWN04+aIAhpOGFhw coOWBH6LN8xQISBQ7rO5GcYUMFMP2sGKPiND+k1ZOobfLzU78Mi23YJcOWCjU0Qq GO6n79rE8B93L6aWlLzyiowh1xcOqcIiszAaZyVUh9jst7k41tbDuDAyLp5gJ964 ajutG6pqWsRh4Fp7C+b2Dr8gUd3RP3mmj71RiEQJU5k/2T9YbBz6e+OyOQCGHzAp BEbxomqbcW9xcKLKRABXNCcFTws26u2CElUFgv4gwLgjrmqXVXrnaO47/DkeeGRx 33QydCoaqHoyE9iSG/UpMPKUgb+n8XX5nRNp4VT4tPf/gYG4g0zYx48mk11prA20 h1hAr31/faQXL3EIV8UUcYh1WDElQqSQvuIDztDGC5YfBceiWiRJ8McNRQAzD1HU pZ58AM8KF1WEHsHOovY7nW5FxrgybkDTDQ8iu6GlWkFSX+EQN7rafcK+6nwD6t7F 1xuxJdXwdolFNrwBe9hvmxzgsR3libwly0FRPTA4Qwrlwr4x/NU= =v7+F -----END PGP SIGNATURE----- --ibTvN161/egqYuK8--