Merge pull request #623 from jonmast/prevent-exec-recursion

Ignore shim directory for executable lookups
This commit is contained in:
Victor Borja 2020-02-14 14:26:03 -06:00 committed by GitHub
commit 62c4fdb163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -707,10 +707,8 @@ with_shim_executable() {
plugin_path=$(get_plugin_path "$plugin_name")
run_within_env() {
local path=$PATH
if [ "system" == "$full_version" ]; then
local path
path=$(echo "$PATH" | sed -e "s|$(asdf_data_dir)/shims||g; s|::|:|g")
fi
executable_path=$(PATH=$path command -v "$shim_name")

View File

@ -3,6 +3,7 @@
load test_helpers
setup() {
cd $BATS_TMPDIR
ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc
cat > $ASDF_CONFIG_FILE <<-EOM
key1 = value1

View File

@ -96,3 +96,13 @@ teardown() {
[ "$status" -eq 0 ]
[ "$output" = "$ASDF_DIR/installs/dummy/1.1/bin/dummy" ]
}
@test "which should not return shim path" {
cd $PROJECT_DIR
echo 'dummy 1.0' > $PROJECT_DIR/.tool-versions
rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
run env PATH=$PATH:$ASDF_DIR/shims asdf which dummy
[ "$status" -eq 1 ]
[ "$output" == "No dummy executable found for dummy 1.0" ]
}