1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2025-11-05 05:51:17 +08:00

fix(install): ensure --unattended is respected (#13275)

Closes #13274
This commit is contained in:
Carlo Sala 2025-08-19 12:46:13 +02:00 committed by GitHub
parent c2a69fe590
commit cef64c465a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,6 +28,7 @@
# CHSH - 'no' means the installer will not change the default shell (default: yes) # 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) # 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) # 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: # 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' # --skip-chsh: has the same behavior as setting CHSH to 'no'
@ -77,6 +78,7 @@ BRANCH=${BRANCH:-master}
CHSH=${CHSH:-yes} CHSH=${CHSH:-yes}
RUNZSH=${RUNZSH:-yes} RUNZSH=${RUNZSH:-yes}
KEEP_ZSHRC=${KEEP_ZSHRC:-no} KEEP_ZSHRC=${KEEP_ZSHRC:-no}
OVERWRITE_CONFIRMATION=${OVERWRITE_CONFIRMATION:-yes}
command_exists() { command_exists() {
@ -342,6 +344,7 @@ setup_zshrc() {
return return
fi fi
if [ $OVERWRITE_CONFIRMATION != "no" ]; then
# Ask user for confirmation before backing up and overwriting # Ask user for confirmation before backing up and overwriting
echo "${FMT_YELLOW}Found ${zdot}/.zshrc." echo "${FMT_YELLOW}Found ${zdot}/.zshrc."
echo "The existing .zshrc will be backed up to .zshrc.pre-oh-my-zsh if overwritten." echo "The existing .zshrc will be backed up to .zshrc.pre-oh-my-zsh if overwritten."
@ -357,6 +360,7 @@ setup_zshrc() {
[Nn]*) echo "Overwrite skipped. Existing .zshrc will be kept."; return ;; [Nn]*) echo "Overwrite skipped. Existing .zshrc will be kept."; return ;;
*) echo "Invalid choice. Overwrite skipped. Existing .zshrc will be kept."; return ;; *) echo "Invalid choice. Overwrite skipped. Existing .zshrc will be kept."; return ;;
esac esac
fi
if [ -e "$OLD_ZSHRC" ]; then if [ -e "$OLD_ZSHRC" ]; then
OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)"
@ -510,12 +514,13 @@ main() {
if [ ! -t 0 ]; then if [ ! -t 0 ]; then
RUNZSH=no RUNZSH=no
CHSH=no CHSH=no
OVERWRITE_CONFIRMATION=no
fi fi
# Parse arguments # Parse arguments
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case $1 in case $1 in
--unattended) RUNZSH=no; CHSH=no ;; --unattended) RUNZSH=no; CHSH=no; OVERWRITE_CONFIRMATION=no ;;
--skip-chsh) CHSH=no ;; --skip-chsh) CHSH=no ;;
--keep-zshrc) KEEP_ZSHRC=yes ;; --keep-zshrc) KEEP_ZSHRC=yes ;;
esac esac