1
0
Fork 0
mirror of synced 2024-10-04 19:18:57 -04:00

Fail when no modules defined in .zimrc

instead of allowing xargs to execute the action with no positional
parameters.

Also don't try to write to .latest_version if there's no write
permission. This is supposed to be a background/optional operation, so
we don't want to show an error message in this case.

And use Zsh globs instead of find with -exec, and find won't fail if
there's an error with the -exec command.
This commit is contained in:
Eric Nielsen 2020-01-26 15:33:17 -05:00
parent cbf142a988
commit 6129062139
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
5 changed files with 21 additions and 9 deletions

View file

@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- "no such file or directory" error before initial check for latest version.
- Show error when no modules defined in .zimrc, instead of allowing xargs to
execute the action with no positional parameters.
## [1.1.0] - 2020-01-20

View file

@ -1,8 +1,13 @@
_zimfw_source_zimrc() {
local -r ztarget=<%= home %>/.zimrc
local -ri _zprepare_xargs=${1}
local -i _zfailed=0
if ! source <%= home %>/.zimrc || (( _zfailed )); then
print -u2 -PR "%F{red}<%= failed %>Failed to source %B<%= home %>/.zimrc%b%f"
if ! source ${ztarget} || (( _zfailed )); then
print -u2 -PR "%F{red}<%= failed %>Failed to source %B${ztarget}%b%f"
return 1
fi
if (( _zprepare_xargs && ! ${#_zmodules_xargs} )); then
print -u2 -PR "%F{red}<%= failed %>No modules defined in %B${ztarget}%b%f"
return 1
fi
}

View file

@ -3,7 +3,7 @@ _zimfw_version_check() {
setopt LOCAL_OPTIONS EXTENDED_GLOB
local -r ztarget=${ZIM_HOME}/.latest_version
# If .latest_version does not exist or was not modified in the last 30 days
if [[ ! -f ${ztarget}(#qNm-30) ]]; then
if [[ -w ${ztarget:h} && ! -f ${ztarget}(#qNm-30) ]]; then
command git ls-remote --tags --refs https://github.com/zimfw/zimfw.git 'v*' | \
command sed 's?^.*/v??' | command sort -n -t. -k1,1 -k2,2 -k3,3 | \
command tail -n1 >! ${ztarget} &!

View file

@ -1,7 +1,7 @@
_zimfw_clean_compiled() {
local zopt
(( _zprintlevel > 0 )) && zopt='-v'
command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -exec rm -f ${zopt} {} \; || return 1
command rm -f ${zopt} ${ZIM_HOME}/**/*.zwc(|.old) || return 1
command rm -f ${zopt} <%= home %>/<%= startup_files_glob %>.zwc(|.old)(N) || return 1
_zimfw_print -P '<%= done %>Done with clean-compiled. Run %Bzimfw compile%b to re-compile.'
}

View file

@ -228,10 +228,15 @@ Startup options:
}
_zimfw_source_zimrc() {
local -r ztarget=${ZDOTDIR:-${HOME}}/.zimrc
local -ri _zprepare_xargs=${1}
local -i _zfailed=0
if ! source ${ZDOTDIR:-${HOME}}/.zimrc || (( _zfailed )); then
print -u2 -PR "%F{red}Failed to source %B${ZDOTDIR:-${HOME}}/.zimrc%b%f"
if ! source ${ztarget} || (( _zfailed )); then
print -u2 -PR "%F{red}Failed to source %B${ztarget}%b%f"
return 1
fi
if (( _zprepare_xargs && ! ${#_zmodules_xargs} )); then
print -u2 -PR "%F{red}No modules defined in %B${ztarget}%b%f"
return 1
fi
}
@ -241,7 +246,7 @@ _zimfw_version_check() {
setopt LOCAL_OPTIONS EXTENDED_GLOB
local -r ztarget=${ZIM_HOME}/.latest_version
# If .latest_version does not exist or was not modified in the last 30 days
if [[ ! -f ${ztarget}(#qNm-30) ]]; then
if [[ -w ${ztarget:h} && ! -f ${ztarget}(#qNm-30) ]]; then
command git ls-remote --tags --refs https://github.com/zimfw/zimfw.git 'v*' | \
command sed 's?^.*/v??' | command sort -n -t. -k1,1 -k2,2 -k3,3 | \
command tail -n1 >! ${ztarget} &!
@ -258,7 +263,7 @@ _zimfw_version_check() {
_zimfw_clean_compiled() {
local zopt
(( _zprintlevel > 0 )) && zopt='-v'
command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -exec rm -f ${zopt} {} \; || return 1
command rm -f ${zopt} ${ZIM_HOME}/**/*.zwc(|.old) || return 1
command rm -f ${zopt} ${ZDOTDIR:-${HOME}}/.z(shenv|profile|shrc|login|logout).zwc(|.old)(N) || return 1
_zimfw_print -P 'Done with clean-compiled. Run %Bzimfw compile%b to re-compile.'
}
@ -278,7 +283,7 @@ _zimfw_compile() {
}
_zimfw_info() {
print -R 'zimfw version: '${_zversion}' (previous commit is bebbfce)'
print -R 'zimfw version: '${_zversion}' (previous commit is cbf142a)'
print -R 'ZIM_HOME: '${ZIM_HOME}
print -R 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a)