diff --git a/VERSION b/VERSION index 8893a8e..c52af3e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.55 +0.1.56 diff --git a/formula/ih-core.rb b/formula/ih-core.rb index 358961e..32cc8a4 100644 --- a/formula/ih-core.rb +++ b/formula/ih-core.rb @@ -1,5 +1,5 @@ class IhCore < Formula - VERSION="0.1.55" + VERSION="0.1.56" desc "Brew formula for installing core tools used at Included Health engineering." homepage "https://github.com/ConsultingMD/homebrew-ih-public" license "CC BY-NC-ND 4.0" diff --git a/lib/core/shell/step.sh b/lib/core/shell/step.sh index 82c06bc..cfeb943 100644 --- a/lib/core/shell/step.sh +++ b/lib/core/shell/step.sh @@ -104,6 +104,18 @@ function ih::setup::core.shell::install() { export IH_WANT_RE_SOURCE=1 } +function ih::setup::core.shell::private::ensure_correct_ownership() { + local file="$1" + if [[ -e "$file" ]]; then + local current_owner + current_owner=$(stat -f '%Su' "$file") # For macOS + if [[ "$current_owner" != "$(whoami)" ]]; then + echo "Changing ownership of $file to the current user..." + sudo chown "$(whoami)" "$file" + fi + fi +} + # shellcheck disable=SC2016 BOOTSTRAP_SOURCE_LINE=' # This loads the Included Health shell augmentations into your interactive shell @@ -118,6 +130,10 @@ function ih::setup::core.shell::private::configure-bash() { touch ~/.bashrc fi + # prevent permission errors from files accidentally created as root + ih::setup::core.shell::private::ensure_correct_ownership ~/.bash_profile + ih::setup::core.shell::private::ensure_correct_ownership ~/.bashrc + # Check if .bash_profile exists and if it doesn't already source .bashrc, then add it if [[ ! -e ~/.bash_profile ]] || ! grep -q "source ~/.bashrc" ~/.bash_profile; then echo "Ensuring .bash_profile sources .bashrc..." @@ -147,6 +163,9 @@ function ih::setup::core.shell::private::configure-zshrc() { touch "${HOME}/.zshrc" fi + # prevent permission errors from files accidentally created as root + ih::setup::core.shell::private::ensure_correct_ownership ~/.zshrc + # apply fix to support brew completions in zsh: https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh chmod -R go-w "$(brew --prefix)/share"