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.
Feature request
The following code is creating a
.zshrc
file in systems withoutzsh
installed:To avoid that behavior, a condition to check if the file exists will allow the file not to be created with
touch
andsdkman_init_snippet
to only be added when the file exists: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.