Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: check for shadowed binaries in shell installer #1659

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cargo-dist/templates/installer/installer.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ install() {
local _force_install_dir
# Which install layout to use - "flat" or "hierarchical"
local _install_layout="unspecified"
# A list of binaries which are shadowed in the PATH
local _shadowed_bins=""

# Check the newer app-specific variable before falling back
# to the older generic one
Expand Down Expand Up @@ -651,6 +653,24 @@ install() {
say " source $_fish_env_script_path_expr (fish)"
fi
fi

_shadowed_bins="$(check_for_shadowed_bins "$_install_dir" "$_bins")"
if [ -n "$_shadowed_bins" ]; then
say "WARNING: The following commands are shadowed by other commands in your PATH:$_shadowed_bins"
fi
}

check_for_shadowed_bins() {
local _install_dir="$1"
local _bins="$2"

for _bin_name in $_bins; do
if [ "$(command -v "$_bin_name")" != "$_install_dir/$_bin_name" ]; then
_shadowed_bins="$_shadowed_bins $_bin_name"
fi
done

echo "$_shadowed_bins"
}

print_home_for_script() {
Expand Down
20 changes: 20 additions & 0 deletions cargo-dist/tests/snapshots/akaikatana_basic.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions cargo-dist/tests/snapshots/akaikatana_musl.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions cargo-dist/tests/snapshots/akaikatana_two_bin_aliases.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions cargo-dist/tests/snapshots/akaikatana_updaters.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions cargo-dist/tests/snapshots/axolotlsay_abyss.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions cargo-dist/tests/snapshots/axolotlsay_abyss_only.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions cargo-dist/tests/snapshots/axolotlsay_alias.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions cargo-dist/tests/snapshots/axolotlsay_basic.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading