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 #60

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
13 changes: 4 additions & 9 deletions app/views/install_beta.scala.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ sdkman_var_folder="${SDKMAN_DIR}/var"
sdkman_candidates_folder="${SDKMAN_DIR}/candidates"
sdkman_config_file="${sdkman_etc_folder}/config"
sdkman_bash_profile="${HOME}/.bash_profile"
sdkman_profile="${HOME}/.profile"
sdkman_bashrc="${HOME}/.bashrc"
sdkman_zshrc="${ZDOTDIR:-${HOME}}/.zshrc"

Expand Down Expand Up @@ -107,28 +106,24 @@ echo "$SDKMAN_NATIVE_VERSION" > "${SDKMAN_DIR}/var/version_native"

@if(rcUpdate) {
if [[ $darwin == true ]]; then
touch "$sdkman_bash_profile"
echo "Attempt update of login bash profile on OSX..."
if [[ -z $(grep 'sdkman-init.sh' "$sdkman_bash_profile") ]]; then
if [[ -e "$sdkman_bash_profile" && -z $(grep 'sdkman-init.sh' "$sdkman_bash_profile") ]]; then
echo -e "\n$sdkman_init_snippet" >> "$sdkman_bash_profile"
echo "Added sdkman init snippet to $sdkman_bash_profile"
fi
else
echo "Attempt update of interactive bash profile on regular UNIX..."
touch "${sdkman_bashrc}"
if [[ -z $(grep 'sdkman-init.sh' "$sdkman_bashrc") ]]; then
if [[ -e "${sdkman_bashrc}" && -z $(grep 'sdkman-init.sh' "$sdkman_bashrc") ]]; then
echo -e "\n$sdkman_init_snippet" >> "$sdkman_bashrc"
echo "Added sdkman init snippet to $sdkman_bashrc"
fi
fi

echo "Attempt update of zsh profile..."
touch "$sdkman_zshrc"
if [[ -z $(grep 'sdkman-init.sh' "$sdkman_zshrc") ]]; then
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

}

@includes.install_message(beta)
@includes.install_message(beta)
13 changes: 4 additions & 9 deletions app/views/install_stable.scala.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ sdkman_archives_folder="${SDKMAN_DIR}/archives"
sdkman_candidates_folder="${SDKMAN_DIR}/candidates"
sdkman_config_file="${sdkman_etc_folder}/config"
sdkman_bash_profile="${HOME}/.bash_profile"
sdkman_profile="${HOME}/.profile"
sdkman_bashrc="${HOME}/.bashrc"
sdkman_zshrc="${ZDOTDIR:-${HOME}}/.zshrc"

Expand Down Expand Up @@ -112,28 +111,24 @@ echo "$SDKMAN_VERSION" > "${SDKMAN_DIR}/var/version"

@if(rcUpdate) {
if [[ $darwin == true ]]; then
touch "$sdkman_bash_profile"
echo "Attempt update of login bash profile on OSX..."
if [[ -z $(grep 'sdkman-init.sh' "$sdkman_bash_profile") ]]; then
if [[ -e "$sdkman_bash_profile" && -z $(grep 'sdkman-init.sh' "$sdkman_bash_profile") ]]; then
echo -e "\n$sdkman_init_snippet" >> "$sdkman_bash_profile"
echo "Added sdkman init snippet to $sdkman_bash_profile"
fi
else
echo "Attempt update of interactive bash profile on regular UNIX..."
touch "${sdkman_bashrc}"
if [[ -z $(grep 'sdkman-init.sh' "$sdkman_bashrc") ]]; then
if [[ -e "${sdkman_bashrc}" && -z $(grep 'sdkman-init.sh' "$sdkman_bashrc") ]]; then
echo -e "\n$sdkman_init_snippet" >> "$sdkman_bashrc"
echo "Added sdkman init snippet to $sdkman_bashrc"
fi
fi

echo "Attempt update of zsh profile..."
touch "$sdkman_zshrc"
if [[ -z $(grep 'sdkman-init.sh' "$sdkman_zshrc") ]]; then
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

}

@includes.install_message(beta)
@includes.install_message(beta)