1
0
Fork 0

unix-setup.sh: chsh_to_bash: take actions only if necessary

This commit is contained in:
Pratham Patel 2024-02-19 15:22:47 +05:30
parent 4a08bc2823
commit 2fc85d6324
Signed by: thefossguy
SSH Key Fingerprint: SHA256:/B3wAg7jnMEBQ2JwkebbS/eXVZANDmqRfnd9QkIhxMI
1 changed files with 8 additions and 2 deletions

View File

@ -176,8 +176,14 @@ function chsh_to_bash() {
if [[ "$(uname -s)" == 'Darwin' ]]; then
BREW_BASH="$(brew --prefix)/bin/bash"
echo "${BREW_BASH}" | sudo tee -a /etc/shells
sudo chsh -s "${BREW_BASH}" "${REAL_USER}"
# /etc/shells is world readable, so no need to `sudo` unless modifying
if ! grep "${BREW_BASH}" /etc/shells > /dev/null; then
echo "${BREW_BASH}" | sudo tee -a /etc/shells
fi
if ! finger "${REAL_USER}" | grep -oP "${BREW_BASH}"; then
sudo chsh -s "${BREW_BASH}" "${REAL_USER}"
fi
fi
}
function common_setup() {