summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Cornellà <marc@mcornella.com>2025-01-23 21:06:00 +0100
committerGitHub <noreply@github.com>2025-01-23 21:06:00 +0100
commit85c49414926ad86f76d7bad3635f948bb5f883cb (patch)
tree27f4e42542961ad03891061d02bedf9d34f0c49f
parentd2e79501b252ffafa2a25b541f67332c3e186807 (diff)
downloadzsh-85c49414926ad86f76d7bad3635f948bb5f883cb.tar.gz
zsh-85c49414926ad86f76d7bad3635f948bb5f883cb.tar.bz2
zsh-85c49414926ad86f76d7bad3635f948bb5f883cb.zip
fix(cli)!: remove harmful `--unattended` flag for `omz update` (#12935)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
-rw-r--r--README.md11
-rw-r--r--lib/cli.zsh15
2 files changed, 20 insertions, 6 deletions
diff --git a/README.md b/README.md
index 58828cf7f..f7455228a 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 c63185a3d..aed86e758 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