From 23da5508cca9851f915d69dd56285a7bd8c0b1cb Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Thu, 28 Sep 2017 07:03:23 -0400 Subject: [PATCH] Reduce subshell forks with variable By following the established pattern in https://github.com/Bash-it/bash-it/blob/master/completion/available/system.completion.bash#L17-L22 we can reduce the amount of `fork` calls that are made. Signed-off-by: Mike Fiedler --- completion/available/brew.completion.bash | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/completion/available/brew.completion.bash b/completion/available/brew.completion.bash index 596d3905..5cbd1595 100644 --- a/completion/available/brew.completion.bash +++ b/completion/available/brew.completion.bash @@ -1,9 +1,11 @@ if which brew >/dev/null 2>&1; then - if [ -f `brew --prefix`/etc/bash_completion.d/brew ]; then - . `brew --prefix`/etc/bash_completion.d/brew + BREW_PREFIX=$(brew --prefix) + + if [ -f "$BREW_PREFIX"/etc/bash_completion.d/brew ]; then + . "$BREW_PREFIX"/etc/bash_completion.d/brew fi - if [ -f `brew --prefix`/Library/Contributions/brew_bash_completion.sh ]; then - . `brew --prefix`/Library/Contributions/brew_bash_completion.sh + if [ -f "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh ]; then + . "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh fi fi