|
From: | Bob Proulx |
Subject: | Re: [Help-bash] Waiting for a sub-process to finish |
Date: | Thu, 1 Jun 2017 19:08:50 -0600 |
User-agent: | NeoMutt/20170306 (1.8.0) |
João Eiras wrote: > long_command -o >(gzip -c > file.gz) > if gzip -dc file.gz | grep -q bad_line; then ... > This happens because the subprocess ">(gzip -c > file.gz)" has not had time > to finish and close the output file. ... > Question: How can I force bash to wait until all subprocesses to finish ? I complained about this exact same problem back in 2007. And apparently I was the first complaint about it. :-} https://lists.gnu.org/archive/html/bug-bash/2007-09/msg00019.html Some years later I learned the trick of "| cat" to use closure of the file handles to join these asynchronous processes up. But I still avoid it because I think it would be confusing to later programmers reading the code. I still think this is surprising behavior and something that the bash should wait for automatically. Bob
[Prev in Thread] | Current Thread | [Next in Thread] |