1
0
Fork 0
mirror of synced 2024-09-27 21:16:56 -04:00

Don't upgrade zimfw.zsh if not in a writable path

or if it's a symlink or not a regular file. This makes more sense now
that zimfw.zsh can exist outside ZIM_HOME, that the same file can be
used my multiple users in the same machine, and that it is going to be
possible to install it with a package manager once it's stable to do so.
This commit is contained in:
Eric Nielsen 2024-06-18 17:13:53 -05:00
parent 897afc9cf9
commit 3e812ed311
No known key found for this signature in database
GPG key ID: 678AF5E338C87D99
3 changed files with 25 additions and 4 deletions

View file

@ -11,8 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Don't allow calling `zmodule` from the command line. Let it fail with "command
not found" instead, as it's intended to be used only in the .zimrc script.
- `ZIM_HOME` must be defined before sourcing zimfw.zsh. All documentation was
already doing so, hence not considering this is a breaking change.
- Allow zimfw.zsh to exist anywhere else, not only inside `ZIM_HOME`. This
enables installing the zimfw.zsh script independently with a package manager.
- Don't try to upgrade if sourced zimfw.zsh is not in a writable path or is a
symlink.
### Fixed
@ -148,7 +152,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[here](https://github.com/zimfw/completion/blob/9386a76eac3f55b1c04d57d26238f725b4b3ba25/init.zsh#L10-L11).
- Don't compile user Zsh startup scripts anymore
(See [#450](https://github.com/zimfw/zimfw/pull/450)). This means you can:
- either manually delete the compiled files, as they won't be updated by Zim
- either manually delete the compiled files, as they won't be updated by zimfw
anymore (recommended):
```
for zfile in ${ZDOTDIR:-${HOME}}/.z(shenv|profile|shrc|login|logout); do
@ -349,7 +353,7 @@ Take your time to review the updated [README.md] and the changes listed below.
- The Zim "core" is reduced to a single file, namely zimfw.zsh, that is
self-updated without requiring git. With this, `ZIM_HOME` is not (the root of)
a git repo anymore.
- Zsh and modules are configured in .zshrc instead of .zimrc.
- Zsh and modules are initialized in .zshrc instead of .zimrc.
- .zimrc is not sourced during Zsh startup anymore, and only contains the module
definitions.
- Zim's init.zsh and login_init.zsh scripts are generated by the `zimfw` CLI
@ -388,7 +392,8 @@ Take your time to review the updated [README.md] and the changes listed below.
[termtitle]: https://github.com/zimfw/termtitle
[s1ck94]: https://github.com/zimfw/s1ck94
[Unreleased]: https://github.com/zimfw/zimfw/compare/v1.13.0...HEAD
[Unreleased]: https://github.com/zimfw/zimfw/compare/v1.13.1...HEAD
[1.13.1]: https://github.com/zimfw/zimfw/compare/v1.13.0...v1.13.1
[1.13.0]: https://github.com/zimfw/zimfw/compare/v1.12.1...v1.13.0
[1.12.1]: https://github.com/zimfw/zimfw/compare/v1.12.0...v1.12.1
[1.12.0]: https://github.com/zimfw/zimfw/compare/v1.11.3...v1.12.0

View file

@ -1,5 +1,13 @@
_zimfw_upgrade() {
if [[ ! -w ${__ZIMFW_PATH} ]]; then
print -u2 -R $'<%= red %>No write access to <%= bold %>'${__ZIMFW_PATH}$'<%= normalred %>. Will not try to upgrade.<%= normal %>'
return 1
fi
local -r ztarget=${__ZIMFW_PATH}/zimfw.zsh zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
if [[ -L ${ztarget} || ! -f ${ztarget} ]]; then
print -u2 -R $'<%= red %><%= bold %>'${ztarget}$'<%= normalred %> is a symlink or not a regular file. Will not try to upgrade.<%= normal %>'
return 1
fi
{
if (( ${+commands[curl]} )); then
command curl -fsSL -o ${ztarget}.new.gz ${zurl} || return 1

View file

@ -462,7 +462,7 @@ _zimfw_compile() {
}
_zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2024-06-17 12:21:22 UTC, previous commit is 76164d6)'
print -R 'zimfw version: '${_zversion}' (built at 2024-06-18 22:08:02 UTC, previous commit is 897afc9)'
local zparam
for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZIM_HOME ZSH_VERSION; do
print -R ${(r.22....:.)zparam}${(P)zparam}
@ -482,7 +482,15 @@ _zimfw_uninstall() {
}
_zimfw_upgrade() {
if [[ ! -w ${__ZIMFW_PATH} ]]; then
print -u2 -R $'\E[31mNo write access to \E[1m'${__ZIMFW_PATH}$'\E[0;31m. Will not try to upgrade.\E[0m'
return 1
fi
local -r ztarget=${__ZIMFW_PATH}/zimfw.zsh zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
if [[ -L ${ztarget} || ! -f ${ztarget} ]]; then
print -u2 -R $'\E[31m\E[1m'${ztarget}$'\E[0;31m is a symlink or not a regular file. Will not try to upgrade.\E[0m'
return 1
fi
{
if (( ${+commands[curl]} )); then
command curl -fsSL -o ${ztarget}.new.gz ${zurl} || return 1