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

Feature: Append sdkman_init_snippet only when profile-file exists #59

Open
carlosdgomez opened this issue Apr 15, 2022 · 0 comments
Open

Comments

@carlosdgomez
Copy link

carlosdgomez commented Apr 15, 2022

Feature request

The following code is creating a .zshrc file in systems without zsh installed:

echo "Attempt update of zsh profile..."
touch "$sdkman_zshrc"
if [[ -z $(grep 'sdkman-init.sh' "$sdkman_zshrc") ]]; then
    echo -e "\n$sdkman_init_snippet" >> "$sdkman_zshrc"
    echo "Updated existing ${sdkman_zshrc}"
fi

To avoid that behavior, a condition to check if the file exists will allow the file not to be created with touch and sdkman_init_snippet to only be added when the file exists:

echo "Attempt update of zsh profile..."
if [[ -e "$sdkman_zshrc" && -z $(grep 'sdkman-init.sh' "$sdkman_zshrc") ]]; then
    echo -e "\n$sdkman_init_snippet" >> "$sdkman_zshrc"
    echo "Updated existing ${sdkman_zshrc}"
fi

Files to be refactored

  • sdkman-hooks/app/views/install_beta.scala.txt
  • sdkman-hooks/app/views/install_stable.scala.txt

Comments

Same strategy should be used for the other profile-files being supported so as to keep consistency.

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 a pull request may close this issue.

1 participant