Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16583
| From | Rusty Bird <rustybird@net-c.com> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | 'foo > >(bar)' doesn't set $! for external foo not invoked via 'command' |
| Date | 2020-07-19 20:48 +0000 |
| Message-ID | <mailman.159.1595192327.24492.bug-bash@gnu.org> (permalink) |
| References | <20200719204836.GA1184@mutt> |
[Multipart message — attachments visible in raw view] - view raw
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
Back to gnu.bash.bug | Previous | Next | Find similar
'foo > >(bar)' doesn't set $! for external foo not invoked via 'command' Rusty Bird <rustybird@net-c.com> - 2020-07-19 20:48 +0000
csiph-web