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: don't generate on error if backup file doesn't exists #1057

Merged
merged 1 commit into from Dec 23, 2021

Conversation

JrCs
Copy link
Contributor

@JrCs JrCs commented Sep 27, 2021

Signed-off-by: JrCs 90z7oey02@sneakemail.com

Summary

If the replacement (sed) is not done the backup file isn't create and the rm command return on error.
With rm -f no error is generated even if the file doesn't exists.

@JrCs JrCs requested a review from a team as a code owner September 27, 2021 09:58
Signed-off-by: JrCs <90z7oey02@sneakemail.com>
@JrCs JrCs changed the title Don't generate on error if backup file doesn't exists fix: don't generate on error if backup file doesn't exists Sep 27, 2021
@Stratus3D
Copy link
Member

Thanks for the PR @JrCs! Are there any open issues reporting this problem? What OS and version are you on? Can you provide the output from asdf info so we can understand what environment(s) experience this issue?

@jthegedus
Copy link
Contributor

@JrCs could create a test that reproduces this issue which we can then use to validate that this change is necessary?

@JrCs
Copy link
Contributor Author

JrCs commented Oct 10, 2021

@jthegedus if you call asdf with a bash script that use a set -u asdf will stop if it can't remove the backup file.
I don't have another test for this.

@jthegedus
Copy link
Contributor

jthegedus commented Oct 10, 2021

Thanks for sharing, asdf is not yet compatible with -u. There's probably a better way for us to handle the error than performing -f on rm. Can you look into alternatives?

@Stratus3D
Copy link
Member

@JrCs , do you know why that happens? set -u causes bash to exit when an unset variable is encountered. I wouldn't expect these changes to affect anything related to that as no new variables are used. Am I missing something here?

@JrCs
Copy link
Contributor Author

JrCs commented Oct 21, 2021

@Stratus3D i use also set -e to causes bash to exit when a command exit with a code different than 0.

@Stratus3D
Copy link
Member

@JrCs can you share a little more about how you invoked asdf after setting set -e? I'm curious how this setting outside of the asdf codebase is affect it.

@JrCs
Copy link
Contributor Author

JrCs commented Dec 23, 2021

@Stratus3D easy: do a set -eu in your current shell then call asdf.
For my use case the set -e is done by my CI pipeline for the current shell.

@Stratus3D
Copy link
Member

Hmm... I am unable to reproduce this issue on OSX using Zsh:

$ set -e
$ asdf local lua 5.3.3
$ asdf reshim

Both commands succeed without any issues with this fix.

This is not a big deal to me, as I'd eventually like to move to having set -e set inside asdf, and these changes are one step closer to making that possible. Thanks for the PR @JrCs ! I am merging now.

@Stratus3D Stratus3D merged commit 288468f into asdf-vm:master Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants