diff options
| author | Carlo Sala <carlosalag@protonmail.com> | 2025-08-19 12:46:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-19 12:46:13 +0200 |
| commit | cef64c465aa81b68fbbec5b008eeae1cb63805d3 (patch) | |
| tree | e8639b431f2d3839cf7cfb17b13f4f91a109a0a5 | |
| parent | c2a69fe5904e074f0049a941c09f039acdce40a3 (diff) | |
| download | zsh-cef64c465aa81b68fbbec5b008eeae1cb63805d3.tar.gz zsh-cef64c465aa81b68fbbec5b008eeae1cb63805d3.tar.bz2 zsh-cef64c465aa81b68fbbec5b008eeae1cb63805d3.zip | |
fix(install): ensure `--unattended` is respected (#13275)
Closes #13274
| -rwxr-xr-x | tools/install.sh | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/tools/install.sh b/tools/install.sh index d274c2c9f..8cf62a76e 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -25,9 +25,10 @@ # BRANCH - branch to check out immediately after install (default: master) # # Other options: -# CHSH - 'no' means the installer will not change the default shell (default: yes) -# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes) -# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no) +# CHSH - 'no' means the installer will not change the default shell (default: yes) +# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes) +# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no) +# OVERWRITE_CONFIRMATION - 'no' means the installer will not ask for confirmation to overwrite the existing .zshrc (default: yes) # # You can also pass some arguments to the install script to set some these options: # --skip-chsh: has the same behavior as setting CHSH to 'no' @@ -77,6 +78,7 @@ BRANCH=${BRANCH:-master} CHSH=${CHSH:-yes} RUNZSH=${RUNZSH:-yes} KEEP_ZSHRC=${KEEP_ZSHRC:-no} +OVERWRITE_CONFIRMATION=${OVERWRITE_CONFIRMATION:-yes} command_exists() { @@ -342,21 +344,23 @@ setup_zshrc() { return fi - # Ask user for confirmation before backing up and overwriting - echo "${FMT_YELLOW}Found ${zdot}/.zshrc." - echo "The existing .zshrc will be backed up to .zshrc.pre-oh-my-zsh if overwritten." - echo "Make sure your .zshrc contains the following minimal configuration if you choose not to overwrite it:${FMT_RESET}" - echo "----------------------------------------" - cat "$ZSH/templates/minimal.zshrc" - echo "----------------------------------------" - printf '%sDo you want to overwrite it with the Oh My Zsh template? [Y/n]%s ' \ - "$FMT_YELLOW" "$FMT_RESET" - read -r opt - case $opt in - [Yy]*|"") ;; - [Nn]*) echo "Overwrite skipped. Existing .zshrc will be kept."; return ;; - *) echo "Invalid choice. Overwrite skipped. Existing .zshrc will be kept."; return ;; - esac + if [ $OVERWRITE_CONFIRMATION != "no" ]; then + # Ask user for confirmation before backing up and overwriting + echo "${FMT_YELLOW}Found ${zdot}/.zshrc." + echo "The existing .zshrc will be backed up to .zshrc.pre-oh-my-zsh if overwritten." + echo "Make sure your .zshrc contains the following minimal configuration if you choose not to overwrite it:${FMT_RESET}" + echo "----------------------------------------" + cat "$ZSH/templates/minimal.zshrc" + echo "----------------------------------------" + printf '%sDo you want to overwrite it with the Oh My Zsh template? [Y/n]%s ' \ + "$FMT_YELLOW" "$FMT_RESET" + read -r opt + case $opt in + [Yy]*|"") ;; + [Nn]*) echo "Overwrite skipped. Existing .zshrc will be kept."; return ;; + *) echo "Invalid choice. Overwrite skipped. Existing .zshrc will be kept."; return ;; + esac + fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" @@ -510,12 +514,13 @@ main() { if [ ! -t 0 ]; then RUNZSH=no CHSH=no + OVERWRITE_CONFIRMATION=no fi # Parse arguments while [ $# -gt 0 ]; do case $1 in - --unattended) RUNZSH=no; CHSH=no ;; + --unattended) RUNZSH=no; CHSH=no; OVERWRITE_CONFIRMATION=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac |
