Skip to content

Commit

Permalink
Merge pull request #1659 from axodotdev/warn-shadowed-path
Browse files Browse the repository at this point in the history
feat: check for shadowed binaries in shell installer
  • Loading branch information
duckinator authored Dec 20, 2024
2 parents a6a86af + faaf04f commit c158b7d
Show file tree
Hide file tree
Showing 47 changed files with 960 additions and 0 deletions.
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

0 comments on commit c158b7d

Please sign in to comment.