From c8e962d5bf24dea72fdd6d8aa69d2f332af94283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joe=CC=81l=20hawkins=20torres?= Date: Wed, 10 Apr 2024 17:57:34 -0700 Subject: [PATCH] fix(yarn): fix yarn completion bug if 'cd' alias exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This simply replaces all instances of 'cd' with 'builtin cd' in the yarn completion definition. e.g. cd is redefined to ls new directory ```shell cd () { builtin cd "$@" ls -G -laFhTG } ``` this will cause an infinite loop when user invokes `yarn ` Signed-off-by: joél hawkins torres --- plugins/yarn/_yarn | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/yarn/_yarn b/plugins/yarn/_yarn index f15756ff4..9ffe5660c 100644 --- a/plugins/yarn/_yarn +++ b/plugins/yarn/_yarn @@ -86,7 +86,7 @@ _global_commands=( ) _yarn_find_package_json() { - local dir=$(cd "$1" && pwd) + local dir=$(builtin cd "$1" && pwd) while true do @@ -109,7 +109,7 @@ _yarn_commands_scripts() { if [[ -n $opt_args[--cwd] ]]; then packageJson=$(_yarn_find_package_json $opt_args[--cwd]) - binaries=($(cd $opt_args[--cwd] && echo node_modules/.bin/*(x:t))) + binaries=($(builtin cd $opt_args[--cwd] && echo node_modules/.bin/*(x:t))) else packageJson=$(_yarn_find_package_json $pwd) binaries=($(echo node_modules/.bin/*(x:t))) @@ -130,9 +130,9 @@ _yarn_scripts() { if [[ -n $_yarn_run_cwd ]]; then packageJson=$(_yarn_find_package_json $_yarn_run_cwd) if [[ -d "${_yarn_run_cwd}/node_modules" ]]; then - binaries=($(cd $_yarn_run_cwd && echo node_modules/.bin/*(x:t))) + binaries=($(builtin cd $_yarn_run_cwd && echo node_modules/.bin/*(x:t))) else - binaries=($(cd $_yarn_run_cwd && yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1')) + binaries=($(builtin cd $_yarn_run_cwd && yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1')) fi else packageJson=$(_yarn_find_package_json $pwd)