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

fix: Show warning when any ./lib/commands are marked as executable #1593

Merged
merged 1 commit into from
Sep 10, 2023
Merged
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
12 changes: 12 additions & 0 deletions bin/asdf
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ asdf_cmd() {
fi

if [ -x "$ASDF_CMD_FILE" ]; then
# When '$ASDF_CMD_FILE' is an executable, we are executing a command directly from a plugin.
# Example: https://github.com/asdf-community/asdf-nim/blob/397c14a7f04ad5b91963814afc2e9cc92366e1c5/lib/commands/command-install-deps.bash
# In those cases, the path to that command is always an absolute path. However, this codepath can also be activated if a user accidentally
# marks files in ./lib/commands/* as executable. This code detects when that happens and prints a useful warning message.
if [[ "$ASDF_CMD_FILE" == ./lib/commands/* ]]; then
printf '%s\n' "----------"
printf '%s\n' "asdf: Warning: You are executing an asdf command from \$ASDF_DIR, but we detected that some files have been"
printf '%s\n' " erroneously marked as executable. All files under '$ASDF_DIR/lib/commands' must NOT be marked"
printf '%s\n' " as executable. Otherwise, asdf will not be able to source its core files"
printf '%s\n' "----------"
fi >&2

exec "$ASDF_CMD_FILE" "${@:${args_offset}}"
elif [ -f "$ASDF_CMD_FILE" ]; then
set -- "${@:${args_offset}}"
Expand Down