Skip to content

fix(zim): skip Zim update when Zim is not configured - #286

Open
hlclarog wants to merge 1 commit into
CodelyTV:mainfrom
hlclarog:fix/zim-skip-unconfigured
Open

hlclarog wants to merge 1 commit into
CodelyTV:mainfrom
hlclarog:fix/zim-skip-unconfigured

Conversation

@hlclarog

Copy link
Copy Markdown

Closes #285

Problem

scripts/package/update_all runs under set -u and calls zsh "$ZIM_HOME/zimfw.zsh" unconditionally. When ZIM_HOME is not set, the step aborts with ZIM_HOME: unbound variable, and the run still reports that every package was updated.

Fix

Move the Zim update into scripts/package/src/package_managers/zim.sh, like the other package managers, and guard it the same way the other steps are guarded:

  • zim::is_configured is true only when ZIM_HOME is set and $ZIM_HOME/zimfw.zsh exists.
  • zim::update_all keeps the existing upgrade and update calls and the log::file output unchanged.
  • update_all runs zim::is_configured && output::h2 "馃懡 Zim Framework" && zim::update_all, so the step is skipped silently when Zim is not configured.

Testing

  • With stubbed zsh, log::file and output::answer, under set -euo pipefail:
    • ZIM_HOME unset: zim::is_configured is false and nothing aborts (before: unbound variable);
    • ZIM_HOME set without zimfw.zsh: zim::is_configured is false;
    • ZIM_HOME set with zimfw.zsh: zim::update_all runs zimfw.zsh upgrade then zimfw.zsh update and prints Done, the same as before.
  • scripts/self/static_analysis and scripts/self/lint pass.

update_all runs zsh "$ZIM_HOME/zimfw.zsh" unconditionally under set -u,
so a shell without ZIM_HOME (a zsh setup that does not use Zim, or one
whose .zshenv does not export it) aborts that step with
'ZIM_HOME: unbound variable' while the run still reports success.

Move the Zim update into package_managers/zim.sh, like the other
package managers, and run it only when ZIM_HOME is set and zimfw.zsh
exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update_all: Zim step fails with 'ZIM_HOME: unbound variable' when Zim is not configured

1 participant