From 99e308753b9d5c501a92fc225c2eca1ba634d298 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 4 Nov 2019 09:56:03 -0600 Subject: [PATCH 1/4] bin/brew: unset functions that override builtins Also, enable all Bash builtins --- bin/brew | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/brew b/bin/brew index 77bcb906f7..c088bfcd12 100755 --- a/bin/brew +++ b/bin/brew @@ -19,6 +19,13 @@ symlink_target_directory() { quiet_cd "$directory" && quiet_cd "$target_dirname" && pwd -P } +for cmd in $(compgen -A builtin) +do + unset -f $cmd # Unset functions that override Bash builtins + enable $cmd # Enable all Bash builtins +done +unset cmd + BREW_FILE_DIRECTORY="$(quiet_cd "${0%/*}/" && pwd -P)" HOMEBREW_BREW_FILE="${BREW_FILE_DIRECTORY%/}/${0##*/}" HOMEBREW_PREFIX="${HOMEBREW_BREW_FILE%/*/*}" From 7349178adcd32d0ebc301d7683a8353babfab37d Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 4 Nov 2019 10:18:53 -0600 Subject: [PATCH 2/4] move comments outside the 'for cmd' loop --- bin/brew | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/brew b/bin/brew index c088bfcd12..c9a881fa32 100755 --- a/bin/brew +++ b/bin/brew @@ -19,10 +19,12 @@ symlink_target_directory() { quiet_cd "$directory" && quiet_cd "$target_dirname" && pwd -P } +# Unset functions that override Bash builtins +# Enable all Bash builtins for cmd in $(compgen -A builtin) do - unset -f $cmd # Unset functions that override Bash builtins - enable $cmd # Enable all Bash builtins + unset -f $cmd + enable $cmd done unset cmd From d0d150ace2a49326122ef60ac4604a4f8e098865 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 4 Nov 2019 10:40:53 -0600 Subject: [PATCH 3/4] attempt at rewording the explanatory comment --- bin/brew | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/brew b/bin/brew index c9a881fa32..fd80d71165 100755 --- a/bin/brew +++ b/bin/brew @@ -19,8 +19,7 @@ symlink_target_directory() { quiet_cd "$directory" && quiet_cd "$target_dirname" && pwd -P } -# Unset functions that override Bash builtins -# Enable all Bash builtins +# Enable and use default Bash builtins rather than user-defined functions for cmd in $(compgen -A builtin) do unset -f $cmd From c87d2181269777b64eadb74020de50a57bb05a64 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 4 Nov 2019 11:21:13 -0600 Subject: [PATCH 4/4] re-enable disabled builtins and use them --- bin/brew | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/brew b/bin/brew index fd80d71165..5831791a75 100755 --- a/bin/brew +++ b/bin/brew @@ -20,10 +20,11 @@ symlink_target_directory() { } # Enable and use default Bash builtins rather than user-defined functions -for cmd in $(compgen -A builtin) +builtin enable compgen unset +for cmd in $(builtin compgen -A builtin) do - unset -f $cmd - enable $cmd + builtin unset -f $cmd + builtin enable $cmd done unset cmd