From 02744ff4a07a379e369995ef64ee2095374228d4 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 2 Feb 2024 15:31:32 +0800 Subject: [PATCH 1/3] Don't spam bashrc with commented lines --- scripts/bootstrap/bootstrap-haskell | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/bootstrap/bootstrap-haskell b/scripts/bootstrap/bootstrap-haskell index e145c1c..54fb229 100755 --- a/scripts/bootstrap/bootstrap-haskell +++ b/scripts/bootstrap/bootstrap-haskell @@ -527,7 +527,7 @@ adjust_bashrc() { ;; fish) mkdir -p "${GHCUP_PROFILE_FILE%/*}" - sed -i -e '/# ghcup-env$/ s/^#*/#/' "$(posix_realpath "${GHCUP_PROFILE_FILE}")" + sed -i -e '/# ghcup-env$/d' "$(posix_realpath "${GHCUP_PROFILE_FILE}")" case $1 in 1) printf "\n%s" "set -q GHCUP_INSTALL_BASE_PREFIX[1]; or set GHCUP_INSTALL_BASE_PREFIX \$HOME ; set -gx PATH \$HOME/.cabal/bin $GHCUP_BIN \$PATH # ghcup-env" >> "${GHCUP_PROFILE_FILE}" @@ -538,7 +538,7 @@ adjust_bashrc() { esac ;; bash) - sed -i -e '/# ghcup-env$/ s/^#*/#/' "$(posix_realpath "${GHCUP_PROFILE_FILE}")" + sed -i -e '/# ghcup-env$/d' "$(posix_realpath "${GHCUP_PROFILE_FILE}")" printf "\n%s" "[ -f \"${GHCUP_DIR}/env\" ] && source \"${GHCUP_DIR}/env\" # ghcup-env" >> "${GHCUP_PROFILE_FILE}" case "${plat}" in "Darwin"|"darwin") @@ -557,7 +557,7 @@ adjust_bashrc() { ;; zsh) - sed -i -e '/# ghcup-env$/ s/^#*/#/' "$(posix_realpath "${GHCUP_PROFILE_FILE}")" + sed -i -e '/# ghcup-env$/d' "$(posix_realpath "${GHCUP_PROFILE_FILE}")" printf "\n%s" "[ -f \"${GHCUP_DIR}/env\" ] && source \"${GHCUP_DIR}/env\" # ghcup-env" >> "${GHCUP_PROFILE_FILE}" ;; esac From 942685f396b1373c2b87dc9132b94d28bf1b11f3 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 2 Feb 2024 15:40:17 +0800 Subject: [PATCH 2/3] Also dump env into ~/.profile, fixes #763 --- scripts/bootstrap/bootstrap-haskell | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/bootstrap/bootstrap-haskell b/scripts/bootstrap/bootstrap-haskell index 54fb229..73ef192 100755 --- a/scripts/bootstrap/bootstrap-haskell +++ b/scripts/bootstrap/bootstrap-haskell @@ -561,6 +561,10 @@ adjust_bashrc() { printf "\n%s" "[ -f \"${GHCUP_DIR}/env\" ] && source \"${GHCUP_DIR}/env\" # ghcup-env" >> "${GHCUP_PROFILE_FILE}" ;; esac + if [ -e "$HOME/.profile" ] ; then + sed -i -e '/# ghcup-env$/d' "$(posix_realpath "$HOME/.profile")" + printf "\n%s" "[ -f \"${GHCUP_DIR}/env\" ] && source \"${GHCUP_DIR}/env\" # ghcup-env" >> "$HOME/.profile" + fi echo echo "===============================================================================" echo From 80703d7b291016ec4b05a97e80ea5e5233db92bf Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 2 Feb 2024 16:18:50 +0800 Subject: [PATCH 3/3] Be more portable wrt sourcing scripts --- scripts/bootstrap/bootstrap-haskell | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/bootstrap/bootstrap-haskell b/scripts/bootstrap/bootstrap-haskell index 73ef192..d044440 100755 --- a/scripts/bootstrap/bootstrap-haskell +++ b/scripts/bootstrap/bootstrap-haskell @@ -539,11 +539,11 @@ adjust_bashrc() { ;; bash) sed -i -e '/# ghcup-env$/d' "$(posix_realpath "${GHCUP_PROFILE_FILE}")" - printf "\n%s" "[ -f \"${GHCUP_DIR}/env\" ] && source \"${GHCUP_DIR}/env\" # ghcup-env" >> "${GHCUP_PROFILE_FILE}" + printf "\n%s" "[ -f \"${GHCUP_DIR}/env\" ] && . \"${GHCUP_DIR}/env\" # ghcup-env" >> "${GHCUP_PROFILE_FILE}" case "${plat}" in "Darwin"|"darwin") if ! grep -q "ghcup-env" "${HOME}/.bash_profile" ; then - printf "\n%s" "[[ -f ~/.bashrc ]] && source ~/.bashrc # ghcup-env" >> "${HOME}/.bash_profile" + printf "\n%s" "[[ -f ~/.bashrc ]] && . ~/.bashrc # ghcup-env" >> "${HOME}/.bash_profile" fi ;; MSYS*|MINGW*|CYGWIN*) @@ -558,18 +558,18 @@ adjust_bashrc() { zsh) sed -i -e '/# ghcup-env$/d' "$(posix_realpath "${GHCUP_PROFILE_FILE}")" - printf "\n%s" "[ -f \"${GHCUP_DIR}/env\" ] && source \"${GHCUP_DIR}/env\" # ghcup-env" >> "${GHCUP_PROFILE_FILE}" + printf "\n%s" "[ -f \"${GHCUP_DIR}/env\" ] && . \"${GHCUP_DIR}/env\" # ghcup-env" >> "${GHCUP_PROFILE_FILE}" ;; esac if [ -e "$HOME/.profile" ] ; then sed -i -e '/# ghcup-env$/d' "$(posix_realpath "$HOME/.profile")" - printf "\n%s" "[ -f \"${GHCUP_DIR}/env\" ] && source \"${GHCUP_DIR}/env\" # ghcup-env" >> "$HOME/.profile" + printf "\n%s" "[ -f \"${GHCUP_DIR}/env\" ] && . \"${GHCUP_DIR}/env\" # ghcup-env" >> "$HOME/.profile" fi echo echo "===============================================================================" echo warn "OK! ${GHCUP_PROFILE_FILE} has been modified. Restart your terminal for the changes to take effect," - warn "or type \"source ${GHCUP_DIR}/env\" to apply them in your current terminal session." + warn "or type \". ${GHCUP_DIR}/env\" to apply them in your current terminal session." return ;; *)