Skip to content

Commit 12248b7

Browse files
committed
Improve resolution of backing executable by iterating through all items in PATH
1 parent c298b99 commit 12248b7

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/artifacts-helper/scripts/dotnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ if [ ! -d "${HOME}/.nuget/plugins/netcore" ]; then
88
fi
99

1010
DOTNET_EXE="$(resolve_shim)"
11-
VSS_NUGET_ACCESSTOKEN="${ARTIFACTS_ACCESSTOKEN:-}" VSS_NUGET_URI_PREFIXES=REPLACE_WITH_AZURE_DEVOPS_NUGET_FEED_URL_PREFIX ${NUGET_EXE} "$@"
11+
VSS_NUGET_ACCESSTOKEN="${ARTIFACTS_ACCESSTOKEN:-}" VSS_NUGET_URI_PREFIXES=REPLACE_WITH_AZURE_DEVOPS_NUGET_FEED_URL_PREFIX ${DOTNET_EXE} "$@"

src/artifacts-helper/scripts/resolve-shim.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ RESOLVE_SHIMS_IMPORTED=true
44

55
resolve_shim() {
66
# Find the next non-shim executable in PATH so we do not run the shim again
7-
shim_file=$(readlink -f "${BASH_SOURCE[1]}")
8-
echo $(which -a dotnet | grep -vx "$shim_file" | head -n 1)
7+
shim_file="$(readlink -f "${BASH_SOURCE[1]}")"
8+
executable="$(basename "$shim_file")"
9+
10+
# Read into array first to handle spaces properly
11+
readarray -t candidates < <(which -a "$executable" 2>/dev/null)
12+
13+
for candidate in "${candidates[@]}"; do
14+
# Skip any candidate which is a symlink to the shim file
15+
[[ "$(readlink -f "$candidate")" != "$shim_file" ]] && {
16+
echo "$candidate"
17+
return 0
18+
}
19+
done
20+
21+
return 1
922
}

0 commit comments

Comments
 (0)