From 15b42301e55269d779a81e4a348ea92a3f16e4a0 Mon Sep 17 00:00:00 2001 From: Martin Afanasjew Date: Wed, 6 Apr 2016 01:52:25 +0200 Subject: [PATCH] brew.sh: make analytics 'curl' fully asynchronous If analytics are enabled and `brew` is used in a command substitution context, e.g. `brew search` for tab completion, the result is that even though the Google Analytics `curl` process runs in the background it still is attached to the captured `stdout`, thus could theoretically contribute to the result of the command substitution and consequently makes the command substitution block on the completion of this process. Redirecting `stdout` (and `stderr` for good measure) to `/dev/null` makes this process truly asynchronous in these contexts. Furthermore, even if the process is in the background, it is still included in the shell's job list and thus shell internals like `wait` (used in `cmd/update.sh`) have to wait on this process, even if they never intended to do so. Removing the analytics process from the job list via `disown` avoids this unintended effect. Fixes #29. Closes #34. Signed-off-by: Martin Afanasjew --- Library/brew.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/brew.sh b/Library/brew.sh index cbde0e7c4c..78f42ba3d5 100644 --- a/Library/brew.sh +++ b/Library/brew.sh @@ -228,7 +228,8 @@ then -d av="$HOMEBREW_VERSION" \ -d t=screenview \ -d cd="$HOMEBREW_COMMAND" \ - & + &> /dev/null \ + & disown fi if [[ -n "$HOMEBREW_BASH_COMMAND" ]]