diff --git a/CHANGELOG.md b/CHANGELOG.md index 89e1741..0e42b04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/stage2/31_zimfw_source_zimrc.zsh.erb b/src/stage2/31_zimfw_source_zimrc.zsh.erb index c8d79b1..a6b8966 100644 --- a/src/stage2/31_zimfw_source_zimrc.zsh.erb +++ b/src/stage2/31_zimfw_source_zimrc.zsh.erb @@ -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 } diff --git a/src/stage2/40_zimfw_version_check.zsh.erb b/src/stage2/40_zimfw_version_check.zsh.erb index 81b303b..f33d7a1 100644 --- a/src/stage2/40_zimfw_version_check.zsh.erb +++ b/src/stage2/40_zimfw_version_check.zsh.erb @@ -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} &! diff --git a/src/stage2/50_zimfw_clean_compiled.zsh.erb b/src/stage2/50_zimfw_clean_compiled.zsh.erb index 6082665..d334771 100644 --- a/src/stage2/50_zimfw_clean_compiled.zsh.erb +++ b/src/stage2/50_zimfw_clean_compiled.zsh.erb @@ -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.' } diff --git a/zimfw.zsh b/zimfw.zsh index 441939d..9269f0b 100644 --- a/zimfw.zsh +++ b/zimfw.zsh @@ -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)