From 39909e01af2bbf23fc821de5cec6c5c9661c59bb Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Fri, 6 May 2022 09:21:06 -0400 Subject: [PATCH] fix: add asdf to list of banned commands (#1224) Ban recusive asdf calls as they are inefficient and may introduce bugs. If you find yourself needing to invoke an `asdf` command from within asdf code, please source the appropriate file and invoke the corresponding function. --- lib/asdf.sh | 2 +- lib/commands/reshim.bash | 2 +- test/banned_commands.bats | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/asdf.sh b/lib/asdf.sh index 7ad83741e..f43aae581 100644 --- a/lib/asdf.sh +++ b/lib/asdf.sh @@ -13,7 +13,7 @@ asdf() { ;; *) # forward other commands to asdf script - command asdf "$command" "$@" + command asdf "$command" "$@" # asdf_allow: ' asdf ' ;; esac diff --git a/lib/commands/reshim.bash b/lib/commands/reshim.bash index be6fd655a..0c0fb52aa 100644 --- a/lib/commands/reshim.bash +++ b/lib/commands/reshim.bash @@ -97,7 +97,7 @@ write_shim_script() { cat <"$shim_path" #!/usr/bin/env bash # asdf-plugin: ${plugin_name} ${version} -exec $(asdf_dir)/bin/asdf exec "${executable_name}" "\$@" +exec $(asdf_dir)/bin/asdf exec "${executable_name}" "\$@" # asdf_allow: ' asdf ' EOF fi diff --git a/test/banned_commands.bats b/test/banned_commands.bats index 360354af3..d2a81f868 100644 --- a/test/banned_commands.bats +++ b/test/banned_commands.bats @@ -41,6 +41,12 @@ banned_commands_regex=( # match certain filename patterns. # https://github-wiki-see.page/m/koalaman/shellcheck/wiki/SC2012 '\bls ' + + # Ban recusive asdf calls as they are inefficient and may introduce bugs. + # If you find yourself needing to invoke an `asdf` command from within + # asdf code, please source the appropriate file and invoke the + # corresponding function. + '\basdf ' ) setup() {