Don't depend on cmp
and xargs
as they requires busybox or diffutils and findutils. Use `cksum` and `zargs` instead. Fixes #393
This commit is contained in:
parent
7e369ef9cf
commit
8724686e85
6 changed files with 27 additions and 18 deletions
|
@ -7,7 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
_No unreleased changes._
|
### Changed
|
||||||
|
- Use `cksum` instead of `cmp`, and `zargs` instead of `xargs`, so we don't
|
||||||
|
depend on busybox or diffutils and findutils.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Error messages and the `zmodule` usage text.
|
||||||
|
|
||||||
## [1.1.1] - 2020-01-26
|
## [1.1.1] - 2020-01-26
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
_zimfw_mv() {
|
_zimfw_mv() {
|
||||||
if command cmp -s ${2} ${1}; then
|
local -a cklines=(${(f)"$(command cksum ${@})"})
|
||||||
|
if [[ ${${(z)cklines[1]}[1,2]} == ${${(z)cklines[2]}[1,2]} ]]; then
|
||||||
_zimfw_print -PR "<%= okay %>%B${2}:%b Already up to date"
|
_zimfw_print -PR "<%= okay %>%B${2}:%b Already up to date"
|
||||||
else
|
else
|
||||||
if [[ -e ${2} ]]; then
|
if [[ -e ${2} ]]; then
|
||||||
|
|
|
@ -108,9 +108,9 @@ Initialization options:
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
if (( _zprepare_xargs )); then
|
if (( _zprepare_zargs )); then
|
||||||
if (( ! zfrozen )); then
|
if (( ! zfrozen )); then
|
||||||
_zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zprintlevel}$'\0'
|
_zmodules_zargs+=(${zmodule} ${zdir} ${zurl} ${ztype} ${zrev} ${_zprintlevel})
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if (( zdisabled )); then
|
if (( zdisabled )); then
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
_zimfw_source_zimrc() {
|
_zimfw_source_zimrc() {
|
||||||
local -r ztarget=<%= home %>/.zimrc
|
local -r ztarget=<%= home %>/.zimrc
|
||||||
local -ri _zprepare_xargs=${1}
|
local -ri _zprepare_zargs=${1}
|
||||||
local -i _zfailed=0
|
local -i _zfailed=0
|
||||||
if ! source ${ztarget} || (( _zfailed )); then
|
if ! source ${ztarget} || (( _zfailed )); then
|
||||||
print -u2 -PR "%F{red}<%= failed %>Failed to source %B${ztarget}%b%f"
|
print -u2 -PR "%F{red}<%= failed %>Failed to source %B${ztarget}%b%f"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if (( _zprepare_xargs && ! ${#_zmodules_xargs} )); then
|
if (( _zprepare_zargs && ! ${#_zmodules_zargs} )); then
|
||||||
print -u2 -PR "%F{red}<%= failed %>No modules defined in %B${ztarget}%b%f"
|
print -u2 -PR "%F{red}<%= failed %>No modules defined in %B${ztarget}%b%f"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -20,8 +20,8 @@ Options:
|
||||||
%B-q%b Quiet, only outputs errors
|
%B-q%b Quiet, only outputs errors
|
||||||
%B-v%b Verbose
|
%B-v%b Verbose
|
||||||
"
|
"
|
||||||
local ztool _zmodules_xargs
|
local ztool
|
||||||
local -a _zdisableds _zmodules _zfpaths _zfunctions _zscripts
|
local -a _zdisableds _zmodules _zfpaths _zfunctions _zscripts _zmodules_zargs
|
||||||
local -i _zprintlevel=1
|
local -i _zprintlevel=1
|
||||||
if (( # > 2 )); then
|
if (( # > 2 )); then
|
||||||
print -u2 -PR "%F{red}${0}: Too many options%f"$'\n\n'${zusage}
|
print -u2 -PR "%F{red}${0}: Too many options%f"$'\n\n'${zusage}
|
||||||
|
@ -65,7 +65,8 @@ Options:
|
||||||
info) _zimfw_info ;;
|
info) _zimfw_info ;;
|
||||||
install|update)
|
install|update)
|
||||||
_zimfw_source_zimrc 1 || return 1
|
_zimfw_source_zimrc 1 || return 1
|
||||||
print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \
|
autoload -Uz zargs && \
|
||||||
|
zargs -n 9 -P 10 -- ${_zmodules_zargs} -- zsh -c ${ztool} ${1} && \
|
||||||
_zimfw_print -PR "<%= done %>Done with ${1}. Restart your terminal for any changes to take effect." || return 1
|
_zimfw_print -PR "<%= done %>Done with ${1}. Restart your terminal for any changes to take effect." || return 1
|
||||||
(( _zprintlevel-- ))
|
(( _zprintlevel-- ))
|
||||||
_zimfw_source_zimrc && _zimfw_build && _zimfw_compile
|
_zimfw_source_zimrc && _zimfw_build && _zimfw_compile
|
||||||
|
|
20
zimfw.zsh
20
zimfw.zsh
|
@ -37,7 +37,8 @@ _zimfw_print() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_mv() {
|
_zimfw_mv() {
|
||||||
if command cmp -s ${2} ${1}; then
|
local -a cklines=(${(f)"$(command cksum ${@})"})
|
||||||
|
if [[ ${${(z)cklines[1]}[1,2]} == ${${(z)cklines[2]}[1,2]} ]]; then
|
||||||
_zimfw_print -PR "%F{green})%f %B${2}:%b Already up to date"
|
_zimfw_print -PR "%F{green})%f %B${2}:%b Already up to date"
|
||||||
else
|
else
|
||||||
if [[ -e ${2} ]]; then
|
if [[ -e ${2} ]]; then
|
||||||
|
@ -208,9 +209,9 @@ Initialization options:
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
if (( _zprepare_xargs )); then
|
if (( _zprepare_zargs )); then
|
||||||
if (( ! zfrozen )); then
|
if (( ! zfrozen )); then
|
||||||
_zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zprintlevel}$'\0'
|
_zmodules_zargs+=(${zmodule} ${zdir} ${zurl} ${ztype} ${zrev} ${_zprintlevel})
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if (( zdisabled )); then
|
if (( zdisabled )); then
|
||||||
|
@ -240,13 +241,13 @@ Initialization options:
|
||||||
|
|
||||||
_zimfw_source_zimrc() {
|
_zimfw_source_zimrc() {
|
||||||
local -r ztarget=${ZDOTDIR:-${HOME}}/.zimrc
|
local -r ztarget=${ZDOTDIR:-${HOME}}/.zimrc
|
||||||
local -ri _zprepare_xargs=${1}
|
local -ri _zprepare_zargs=${1}
|
||||||
local -i _zfailed=0
|
local -i _zfailed=0
|
||||||
if ! source ${ztarget} || (( _zfailed )); then
|
if ! source ${ztarget} || (( _zfailed )); then
|
||||||
print -u2 -PR "%F{red}Failed to source %B${ztarget}%b%f"
|
print -u2 -PR "%F{red}Failed to source %B${ztarget}%b%f"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if (( _zprepare_xargs && ! ${#_zmodules_xargs} )); then
|
if (( _zprepare_zargs && ! ${#_zmodules_zargs} )); then
|
||||||
print -u2 -PR "%F{red}No modules defined in %B${ztarget}%b%f"
|
print -u2 -PR "%F{red}No modules defined in %B${ztarget}%b%f"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -294,7 +295,7 @@ _zimfw_compile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_info() {
|
_zimfw_info() {
|
||||||
print -R 'zimfw version: '${_zversion}' (previous commit is d1103f3)'
|
print -R 'zimfw version: '${_zversion}' (previous commit is 7e369ef)'
|
||||||
print -R 'ZIM_HOME: '${ZIM_HOME}
|
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||||
print -R 'Zsh version: '${ZSH_VERSION}
|
print -R 'Zsh version: '${ZSH_VERSION}
|
||||||
print -R 'System info: '$(command uname -a)
|
print -R 'System info: '$(command uname -a)
|
||||||
|
@ -359,8 +360,8 @@ Options:
|
||||||
%B-q%b Quiet, only outputs errors
|
%B-q%b Quiet, only outputs errors
|
||||||
%B-v%b Verbose
|
%B-v%b Verbose
|
||||||
"
|
"
|
||||||
local ztool _zmodules_xargs
|
local ztool
|
||||||
local -a _zdisableds _zmodules _zfpaths _zfunctions _zscripts
|
local -a _zdisableds _zmodules _zfpaths _zfunctions _zscripts _zmodules_zargs
|
||||||
local -i _zprintlevel=1
|
local -i _zprintlevel=1
|
||||||
if (( # > 2 )); then
|
if (( # > 2 )); then
|
||||||
print -u2 -PR "%F{red}${0}: Too many options%f"$'\n\n'${zusage}
|
print -u2 -PR "%F{red}${0}: Too many options%f"$'\n\n'${zusage}
|
||||||
|
@ -482,7 +483,8 @@ fi
|
||||||
info) _zimfw_info ;;
|
info) _zimfw_info ;;
|
||||||
install|update)
|
install|update)
|
||||||
_zimfw_source_zimrc 1 || return 1
|
_zimfw_source_zimrc 1 || return 1
|
||||||
print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \
|
autoload -Uz zargs && \
|
||||||
|
zargs -n 9 -P 10 -- ${_zmodules_zargs} -- zsh -c ${ztool} ${1} && \
|
||||||
_zimfw_print -PR "Done with ${1}. Restart your terminal for any changes to take effect." || return 1
|
_zimfw_print -PR "Done with ${1}. Restart your terminal for any changes to take effect." || return 1
|
||||||
(( _zprintlevel-- ))
|
(( _zprintlevel-- ))
|
||||||
_zimfw_source_zimrc && _zimfw_build && _zimfw_compile
|
_zimfw_source_zimrc && _zimfw_build && _zimfw_compile
|
||||||
|
|
Loading…
Reference in a new issue