-
Notifications
You must be signed in to change notification settings - Fork 790
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
asdf plugin add
should exit code 0 in most cases
#841
Comments
@ghostsquad We have had a related discussion of this with #747 I believe a concensus was reached whereby we would remove non-zero exit codes on commands that did not fail, but did not change the state of things (due to an existing plugin as you suggest). As noted in #747 (comment) the Issues and PRs that instituted this behaviour did not receive much feedback from our userbase (which was admittedly smaller) at the time. @asdf-vm/core Are there any objections to addressing this issue with the proposition here #747 (comment) EDIT: #66 also discusses this issue (I believe it was the first discussion) |
If I'm reading the original issue (#322) correctly, it seems that @the-mikedavis also preferred the status code of Pinging @asdf-vm/core / @Stratus3D again, would there be any objections to a PR that changes the exit code back to |
Totally agree. At least give us an option (e.g. similar to |
I made a comment in the other issue, but it looks like it was closed. My code is littered with |
This is a popular request and have linked a PR that resolves this - hopefully it lands in For now, the best workaround is manually checking exit codes: asdf_plugin_add() {
asdf plugin add "$@" || {
local exit_code=$1
# If asdf detects that the plugin is already installed, it prints to standard error,
# then exits with a code of 2. We manually check this case, and return 0 so this
# this script remains idempotent, especially when `errexit` is set.
if ((exit_code == 2)); then
return 0
else
return $exit_code
fi
}
}
asdf_plugin_add <blah> Theoretically, if Git returns with an exit code of 2 if cloning fails, or if a plugin exits with a code of 2, this will give a false positive, but the occurrence of said false positives is still drastically less than compared to without this workaround. |
Is your feature request related to a problem? Please describe.
asdf plugin add
exits with code 2 if the plugin is already added. This isn't a great user experience for automation. From the perspective of the final result, the operation succeeded.Describe the solution you'd like
Exit with code
0
if the plugin is already installed. Possibly check/warn if the current plugin is outdated?Describe similar asdf features and why they are not sufficient
n/a
Describe workarounds you've considered
unfortunately this workaround is problematic in that if it fails for a different and legitimate reason, the script will not be aware.
Additional context
n/a
The text was updated successfully, but these errors were encountered: