From 85c49414926ad86f76d7bad3635f948bb5f883cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 23 Jan 2025 21:06:00 +0100 Subject: [PATCH] fix(cli)!: remove harmful `--unattended` flag for `omz update` (#12935) Co-authored-by: Carlo Sala --- README.md | 11 +++++++++++ lib/cli.zsh | 15 +++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 58828cf7..f7455228 100644 --- a/README.md +++ b/README.md @@ -487,6 +487,17 @@ wait a week?) you just need to run: omz update ``` +> [!NOTE] +> If you want to automate this process in a script, you should call directly the `upgrade` script, like this: +> +> ```sh +> $ZSH/tools/upgrade.sh +> ``` +> +> See more options in the [FAQ: How do I update Oh My Zsh?](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-update-oh-my-zsh). +> +> **USE OF `omz update --unattended` HAS BEEN REMOVED, AS IT HAS SIDE EFFECTS**. + Magic! 🎉 ## Uninstalling Oh My Zsh diff --git a/lib/cli.zsh b/lib/cli.zsh index c63185a3..aed86e75 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -823,6 +823,13 @@ function _omz::update { return 1 } + # Check if --unattended was passed + [[ "$1" != --unattended ]] || { + _omz::log error "the \`\e[2m--unattended\e[0m\` flag is no longer supported, use the \`\e[2mupgrade.sh\e[0m\` script instead." + _omz::log error "for more information see https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-update-oh-my-zsh" + return 1 + } + local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null) [[ $? -eq 0 ]] || { _omz::log error "\`$ZSH\` is not a git directory. Aborting..." @@ -831,11 +838,7 @@ function _omz::update { # Run update script zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default - if [[ "$1" != --unattended ]]; then - ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $? - else - ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -v $verbose_mode || return $? - fi + ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $? # Update last updated file zmodload zsh/datetime @@ -844,7 +847,7 @@ function _omz::update { command rm -rf "$ZSH/log/update.lock" # Restart the zsh session if there were changes - if [[ "$1" != --unattended && "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then + if [[ "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then # Old zsh versions don't have ZSH_ARGZERO local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" # Check whether to run a login shell