diff --git a/CHANGELOG.md b/CHANGELOG.md
index 487c2ad..bf1848c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
-_No unreleased changes._
+
+### Added
+
+- `--if-command` option to zmodule. This option is equivalent to
+ `--if "(( \${+commands[${1}]} ))"`.
## [1.12.1] - 2023-09-16
diff --git a/README.md b/README.md
index fc333ce..53eacf5 100644
--- a/README.md
+++ b/README.md
@@ -255,6 +255,9 @@ Per-module options:
Per-module-root options:
--if <test> Will only initialize module root if specified test returns a zero
exit status. The test is evaluated at every new terminal startup.
+ --if-command <command> Will only initialize module root if specified external command is
+ available. This is evaluated at every new terminal startup.
+ Equivalent to --if "(( \\\${+commands[\${1}]} ))".
--on-pull <command> Execute command after installing or updating the module. The com-
mand is executed in the module root directory.
-d|--disabled Don't initialize the module root or uninstall the module.
diff --git a/src/stage2/30_zmodule.zsh.erb b/src/stage2/30_zmodule.zsh.erb
index 78cb1fa..15093c4 100644
--- a/src/stage2/30_zmodule.zsh.erb
+++ b/src/stage2/30_zmodule.zsh.erb
@@ -36,6 +36,9 @@ Per-module options:
Per-module-root options:
<%= bold %>--if<%= normal %> Will only initialize module root if specified test returns a zero
exit status. The test is evaluated at every new terminal startup.
+ <%= bold %>--if-command<%= normal %> Will only initialize module root if specified external command is
+ available. This is evaluated at every new terminal startup.
+ Equivalent to <%= bold %>--if "(( \\\${+commands[\${1}]} ))"<%= normal %>.
<%= bold %>--on-pull<%= normal %> Execute command after installing or updating the module. The com-
mand is executed in the module root directory.
<%= bold %>-d<%= normal %>|<%= bold %>--disabled<%= normal %> Don\'t initialize the module root or uninstall the module.
@@ -125,7 +128,7 @@ Per-call initialization options:
# Set values from options
while (( # > 0 )); do
case ${1} in
- -b|--branch|-t|--tag|-u|--use|--on-pull|--if|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
+ -b|--branch|-t|--tag|-u|--use|--on-pull|--if|--if-command|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
if (( # < 2 )); then
print -u2 -lR $'<%= red %><%= error %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalred %> Missing argument for zmodule option <%= bold %>'${1}$'<%= normal %>' '' ${zusage}
_zfailed=1
@@ -165,6 +168,10 @@ Per-call initialization options:
shift
_zifs[${zroot_dir}]=${1}
;;
+ --if-command)
+ shift
+ _zifs[${zroot_dir}]="(( \${+commands[${1}]} ))"
+ ;;
-f|--fpath)
shift
zarg=${1}
diff --git a/zimfw.zsh b/zimfw.zsh
index 6b47713..e29fbe4 100644
--- a/zimfw.zsh
+++ b/zimfw.zsh
@@ -106,6 +106,9 @@ _zimfw_build_login_init() {
) ${ztarget}
}
+zeval() {
+}
+
_zimfw_build() {
_zimfw_build_init && _zimfw_build_login_init && _zimfw_print 'Done with build.'
}
@@ -148,6 +151,9 @@ Per-module options:
Per-module-root options:
\E[1m--if\E[0m Will only initialize module root if specified test returns a zero
exit status. The test is evaluated at every new terminal startup.
+ \E[1m--if-command\E[0m Will only initialize module root if specified external command is
+ available. This is evaluated at every new terminal startup.
+ Equivalent to \E[1m--if "(( \\\${+commands[\${1}]} ))"\E[0m.
\E[1m--on-pull\E[0m Execute command after installing or updating the module. The com-
mand is executed in the module root directory.
\E[1m-d\E[0m|\E[1m--disabled\E[0m Don\'t initialize the module root or uninstall the module.
@@ -237,7 +243,7 @@ Per-call initialization options:
# Set values from options
while (( # > 0 )); do
case ${1} in
- -b|--branch|-t|--tag|-u|--use|--on-pull|--if|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
+ -b|--branch|-t|--tag|-u|--use|--on-pull|--if|--if-command|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
if (( # < 2 )); then
print -u2 -lR $'\E[31mx '${funcfiletrace[1]}$':\E[1m'${zname}$':\E[0;31m Missing argument for zmodule option \E[1m'${1}$'\E[0m' '' ${zusage}
_zfailed=1
@@ -277,6 +283,10 @@ Per-call initialization options:
shift
_zifs[${zroot_dir}]=${1}
;;
+ --if-command)
+ shift
+ _zifs[${zroot_dir}]="(( \${+commands[${1}]} ))"
+ ;;
-f|--fpath)
shift
zarg=${1}
@@ -444,7 +454,7 @@ _zimfw_compile() {
}
_zimfw_info() {
- print -R 'zimfw version: '${_zversion}' (built at 2023-09-16 18:25:16 UTC, previous commit is 26151d2)'
+ print -R 'zimfw version: '${_zversion}' (built at 2024-01-23 02:30:19 UTC, previous commit is 5f649d3)'
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}