From fa3be60922596c30f392ba7d73a5f676c2b25038 Mon Sep 17 00:00:00 2001 From: milkeclair Date: Sun, 15 Nov 2026 12:57:43 +0900 Subject: [PATCH 1/5] refactor: capture mod values without success guards --- mod/completion/cache/build/process.zsh | 3 +- mod/completion/cache/load/process.zsh | 3 +- mod/git/branch/analysis.zsh | 3 +- mod/git/branch/merged/get/process.zsh | 6 ++-- mod/git/commit/arg/is/not/operator.zsh | 3 +- mod/git/commit/msg/process.zsh | 15 +++++--- mod/git/commit/process.zsh | 17 ++++++--- mod/git/commit/tag/is/operator.zsh | 3 +- mod/git/commit/tdd/cycle/is/operator.zsh | 3 +- mod/git/hp/analysis.zsh | 3 +- mod/git/stats/author/process.zsh | 44 +++++++++++++++++------- mod/git/stats/commit/details/process.zsh | 7 ++-- mod/git/stats/commit/map/analysis.zsh | 6 ++-- mod/git/stats/commit/process.zsh | 38 ++++++++++++++------ mod/git/stats/exclude/analysis.zsh | 6 ++-- mod/git/stats/process.zsh | 20 +++++++---- mod/job/analysis.zsh | 3 +- mod/job/collect/process.zsh | 10 ++++-- mod/job/file/analysis.zsh | 10 ++++-- mod/job/is/operator.zsh | 3 +- mod/job/meta/process.zsh | 26 ++++++++++---- mod/job/process.zsh | 24 +++++++++---- mod/job/run/operator.zsh | 15 +++++--- mod/job/run/process.zsh | 38 ++++++++++++++------ mod/wtproxy/entry/process.zsh | 3 +- mod/wtproxy/init/config/port/process.zsh | 3 +- mod/wtproxy/rm/process.zsh | 3 +- 27 files changed, 224 insertions(+), 94 deletions(-) diff --git a/mod/completion/cache/build/process.zsh b/mod/completion/cache/build/process.zsh index a9ae5fe..c3b1098 100644 --- a/mod/completion/cache/build/process.zsh +++ b/mod/completion/cache/build/process.zsh @@ -43,7 +43,8 @@ z.completion.cache.build._docs() { # example: # z.completion.cache.build._result result=/tmp/z/job/result z.completion.cache.build._result() { - z.arg.named result "$@" && local result=$REPLY + z.arg.named result "$@" + local result=$REPLY z.is.null "$result" && return 1 z.completion.cache._build diff --git a/mod/completion/cache/load/process.zsh b/mod/completion/cache/load/process.zsh index 1b2528e..5fccecc 100644 --- a/mod/completion/cache/load/process.zsh +++ b/mod/completion/cache/load/process.zsh @@ -7,7 +7,8 @@ # example: # z.completion.cache.load._result result=/tmp/z/job/result z.completion.cache.load._result() { - z.arg.named result "$@" && local result=$REPLY + z.arg.named result "$@" + local result=$REPLY z.is.null "$result" && return 1 source "$result" diff --git a/mod/git/branch/analysis.zsh b/mod/git/branch/analysis.zsh index 907ff9d..e4f51c4 100644 --- a/mod/git/branch/analysis.zsh +++ b/mod/git/branch/analysis.zsh @@ -6,7 +6,8 @@ # example: # z.git.branch.current #=> "main" z.git.branch.current() { - z.git.branch.current._get && local current=$REPLY + z.git.branch.current._get + local current=$REPLY z.io $current } diff --git a/mod/git/branch/merged/get/process.zsh b/mod/git/branch/merged/get/process.zsh index d1358c9..75d9742 100644 --- a/mod/git/branch/merged/get/process.zsh +++ b/mod/git/branch/merged/get/process.zsh @@ -9,7 +9,8 @@ z.git.branch._merged.get.excludes() { local exclude_branches=(main master develop release) - z.arg.named exclude_branches "$@" && local exclude_arg=$REPLY + z.arg.named exclude_branches "$@" + local exclude_arg=$REPLY if z.is.not.null "$exclude_arg"; then z.arr.split "$exclude_arg" exclude_branches=($REPLY) @@ -27,7 +28,8 @@ z.git.branch._merged.get.excludes() { # example: # z.git.branch._merged.get.remove_symbols "* feature/branch" #=> "feature/branch" z.git.branch._merged.get.remove_symbols() { - z.str.trim "$1" && local trimmed=$REPLY + z.str.trim "$1" + local trimmed=$REPLY if z.str.start_with "$trimmed" "*" || z.str.start_with "$trimmed" "+"; then z.arr.split "$trimmed" z.return $REPLY[2] diff --git a/mod/git/commit/arg/is/not/operator.zsh b/mod/git/commit/arg/is/not/operator.zsh index 3a2a242..500a4f1 100644 --- a/mod/git/commit/arg/is/not/operator.zsh +++ b/mod/git/commit/arg/is/not/operator.zsh @@ -8,7 +8,8 @@ # z.git.commit._arg.is.not.no_ticket -m "commit message" #=> true # z.git.commit._arg.is.not.no_ticket -m "commit message" -nt #=> false z.git.commit._arg.is.not.no_ticket() { - z.arg.named opts $@ && local opts=$REPLY + z.arg.named opts $@ + local opts=$REPLY z.str.is.not.match " $opts " "[[:space:]]-nt[[:space:]]" } diff --git a/mod/git/commit/msg/process.zsh b/mod/git/commit/msg/process.zsh index 8d80062..91f1175 100644 --- a/mod/git/commit/msg/process.zsh +++ b/mod/git/commit/msg/process.zsh @@ -12,10 +12,17 @@ # z.git.commit._msg.build tag="feat" message="add new feature" ticket="TICKET-123" cycle="red" # #=> "feat: #TICKET-123 [red] add new feature" z.git.commit._msg.build() { - z.arg.named tag $@ && local tag=$REPLY - z.arg.named message $@ && local message=$REPLY - z.arg.named ticket $@ && local ticket=$REPLY - z.arg.named cycle $@ && local cycle=$REPLY + z.arg.named tag $@ + local tag=$REPLY + + z.arg.named message $@ + local message=$REPLY + + z.arg.named ticket $@ + local ticket=$REPLY + + z.arg.named cycle $@ + local cycle=$REPLY local commit_message="$tag: " z.is.not.null $ticket && commit_message+="#$ticket " diff --git a/mod/git/commit/process.zsh b/mod/git/commit/process.zsh index 7cd701b..a0f3729 100644 --- a/mod/git/commit/process.zsh +++ b/mod/git/commit/process.zsh @@ -61,7 +61,9 @@ z.git.commit() { z.group "extract arguments"; { z.git.commit._arg.extract $@ local -A args=("${(@)REPLY}") - local tag=$args[tag] && local message=$args[message] && local ticket=$args[ticket] + local tag=$args[tag] + local message=$args[message] + local ticket=$args[ticket] z.git.commit._arg.extract.opts "${(@kv)args}" local opts=(${(@)REPLY}) @@ -91,7 +93,8 @@ z.git.commit() { # example: # z.git.commit.tdd red feat "add new feature" TICKET-123 -ca -ae z.git.commit.tdd() { - local cycle=$1 && shift + local cycle=$1 + shift z.git.commit.tdd._cycle.is.valid $cycle || return 1 z.git.commit._arg.is.enough $@ || return 1 @@ -99,7 +102,9 @@ z.git.commit.tdd() { z.group "extract arguments"; { z.git.commit._arg.extract $@ local -A args=("${(@)REPLY}") - local tag=$args[tag] && local message=$args[message] && local ticket=$args[ticket] + local tag=$args[tag] + local message=$args[message] + local ticket=$args[ticket] z.git.commit._arg.extract.opts "${(@kv)args}" local opts=(${(@)REPLY}) @@ -126,7 +131,8 @@ z.git.commit.tdd() { # example: # z.git.commit._with_committer "feat: add new feature" -ca z.git.commit._with_committer() { - local message=$1 && shift + local message=$1 + shift z.git.commit._opts.extract $@ local opts=(${(@)REPLY}) @@ -143,7 +149,8 @@ z.git.commit._with_committer() { # example: # z.git.commit.help z.git.commit.help() { - z.git.commit._tag.list && local tags=$REPLY + z.git.commit._tag.list + local tags=$REPLY z.io.empty z.io indent=1 "Usage:" diff --git a/mod/git/commit/tag/is/operator.zsh b/mod/git/commit/tag/is/operator.zsh index cfa3fbe..fb4122e 100644 --- a/mod/git/commit/tag/is/operator.zsh +++ b/mod/git/commit/tag/is/operator.zsh @@ -8,7 +8,8 @@ # z.git.commit._tag.is.valid "feat" #=> true # z.git.commit._tag.is.valid "invalid_tag" #=> false z.git.commit._tag.is.valid() { - z.git.commit._tag.list && local tag_list="${REPLY[*]}" + z.git.commit._tag.list + local tag_list="${REPLY[*]}" local tag=$1 z.str.split str="$tag_list" delimiter=" " local -a tags=("${(@)REPLY}") diff --git a/mod/git/commit/tdd/cycle/is/operator.zsh b/mod/git/commit/tdd/cycle/is/operator.zsh index 4d1cb0a..d3c6ebe 100644 --- a/mod/git/commit/tdd/cycle/is/operator.zsh +++ b/mod/git/commit/tdd/cycle/is/operator.zsh @@ -8,7 +8,8 @@ # z.git.commit.tdd._cycle.is.valid "red" #=> true # z.git.commit.tdd._cycle.is.valid "invalid_cycle" #=> false z.git.commit.tdd._cycle.is.valid() { - z.git.commit.tdd._cycle.list && local cycle_list="${REPLY[*]}" + z.git.commit.tdd._cycle.list + local cycle_list="${REPLY[*]}" local cycle=$1 z.str.split str="$cycle_list" delimiter=" " local -a cycles=("${(@)REPLY}") diff --git a/mod/git/hp/analysis.zsh b/mod/git/hp/analysis.zsh index 6b3b30f..abcc90e 100644 --- a/mod/git/hp/analysis.zsh +++ b/mod/git/hp/analysis.zsh @@ -7,7 +7,8 @@ # # if current branch is feature/some-description-123 # z.git._hp.ticket #=> "123" z.git._hp.ticket() { - z.git.branch.current._get && local branch=$REPLY + z.git.branch.current._get + local branch=$REPLY # e.g. feature/some-description-123 => some-description-123 z.str.split str=$branch delimiter="/" diff --git a/mod/git/stats/author/process.zsh b/mod/git/stats/author/process.zsh index 93f480b..bfc55e2 100644 --- a/mod/git/stats/author/process.zsh +++ b/mod/git/stats/author/process.zsh @@ -22,9 +22,13 @@ z.git.stats._author.header() { # example: # z.git.stats._author.body exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") z.git.stats._author.body() { - z.arg.named exclude_exts $@ && local exclude_exts=($REPLY) - z.arg.named exclude_dirs $@ && local exclude_dirs=($REPLY) - z.git.stats._author.names && local authors=($REPLY) + z.arg.named exclude_exts $@ + local exclude_exts=($REPLY) + + z.arg.named exclude_dirs $@ + local exclude_dirs=($REPLY) + z.git.stats._author.names + local authors=($REPLY) local commit_map=() z.git.stats._commit.map authors="${authors[*]}" exclude_exts="${exclude_exts[*]}" exclude_dirs="${exclude_dirs[*]}" @@ -68,19 +72,33 @@ z.git.stats._author.body() { # z.git.stats._author.show author="milkeclair" commit_count=100 inserted=1000 deleted=1000 total=2000 # #=> display a table row for milkeclair with her commit stats z.git.stats._author.show() { - z.arg.named author $@ && local author=$REPLY - z.arg.named commit_count $@ && local commit_count=$REPLY - z.arg.named inserted $@ && local inserted=$REPLY - z.arg.named deleted $@ && local deleted=$REPLY - z.arg.named total $@ && local total=$REPLY + z.arg.named author $@ + local author=$REPLY + + z.arg.named commit_count $@ + local commit_count=$REPLY + + z.arg.named inserted $@ + local inserted=$REPLY + + z.arg.named deleted $@ + local deleted=$REPLY + + z.arg.named total $@ + local total=$REPLY z.is.null $author && author="Everyone" - z.str.color red && local red=$REPLY - z.str.color green && local green=$REPLY - z.str.color yellow && local yellow=$REPLY - z.str.color magenta && local magenta=$REPLY - z.str.color reset && local reset=$REPLY + z.str.color red + local red=$REPLY + z.str.color green + local green=$REPLY + z.str.color yellow + local yellow=$REPLY + z.str.color magenta + local magenta=$REPLY + z.str.color reset + local reset=$REPLY # %-20s: ljust 20 for string # %-10d: ljust 10 for digit diff --git a/mod/git/stats/commit/details/process.zsh b/mod/git/stats/commit/details/process.zsh index d391589..8252819 100644 --- a/mod/git/stats/commit/details/process.zsh +++ b/mod/git/stats/commit/details/process.zsh @@ -9,8 +9,11 @@ # z.git.stats._commit.details.excludes exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") # #=> REPLY="\.(md|txt)$ (docs|tests)/" z.git.stats._commit.details.excludes() { - z.arg.named exclude_exts $@ && local exclude_exts_raw=$REPLY - z.arg.named exclude_dirs $@ && local exclude_dirs_raw=$REPLY + z.arg.named exclude_exts $@ + local exclude_exts_raw=$REPLY + + z.arg.named exclude_dirs $@ + local exclude_dirs_raw=$REPLY if z.is.not.null "$exclude_exts_raw"; then z.str.split str="$exclude_exts_raw" delimiter=" " diff --git a/mod/git/stats/commit/map/analysis.zsh b/mod/git/stats/commit/map/analysis.zsh index 5d49d9f..d906df9 100644 --- a/mod/git/stats/commit/map/analysis.zsh +++ b/mod/git/stats/commit/map/analysis.zsh @@ -7,7 +7,8 @@ # example: # z.git.stats._commit.map.split entry="milkeclair:1000 500:50" z.git.stats._commit.map.split() { - z.arg.named entry "$@" && local entry=$REPLY + z.arg.named entry "$@" + local entry=$REPLY z.str.split str="$entry" delimiter=: local parts=($REPLY) @@ -15,7 +16,8 @@ z.git.stats._commit.map.split() { local details=$parts[2] local commit_count=$parts[3] - z.str.split str="$details" delimiter=" " && local lines=($REPLY) + z.str.split str="$details" delimiter=" " + local lines=($REPLY) local inserted=$lines[1] local deleted=$lines[2] z.git.stats._commit.sum_lines inserted=$inserted deleted=$deleted diff --git a/mod/git/stats/commit/process.zsh b/mod/git/stats/commit/process.zsh index 539fc93..22d438f 100644 --- a/mod/git/stats/commit/process.zsh +++ b/mod/git/stats/commit/process.zsh @@ -10,9 +10,14 @@ # z.git.stats._commit.map authors=("Alice" "Bob") exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") # #=> REPLY=("Alice:1000 500:50" "Bob:800 300:40") z.git.stats._commit.map() { - z.arg.named authors $@ && local authors_raw=$REPLY - z.arg.named exclude_exts $@ && local exclude_exts=($REPLY) - z.arg.named exclude_dirs $@ && local exclude_dirs=($REPLY) + z.arg.named authors $@ + local authors_raw=$REPLY + + z.arg.named exclude_exts $@ + local exclude_exts=($REPLY) + + z.arg.named exclude_dirs $@ + local exclude_dirs=($REPLY) local authors=() if z.is.not.null "$authors_raw"; then @@ -26,7 +31,8 @@ z.git.stats._commit.map() { z.git.stats._commit.details author="$author" exclude_exts=$exclude_exts exclude_dirs=$exclude_dirs z.str.split str="$REPLY" delimiter=" " local details=($REPLY) - z.git.stats._commit.count "$author" && local count=$REPLY + z.git.stats._commit.count "$author" + local count=$REPLY if z.int.is.not.zero $count; then local details_str="${details[1]} ${details[2]}" @@ -48,16 +54,23 @@ z.git.stats._commit.map() { # example: # z.git.stats._commit.details author="milkeclair" exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") z.git.stats._commit.details() { - z.arg.named author $@ && local author=$REPLY - z.arg.named exclude_exts $@ && local exclude_exts_raw=$REPLY - z.arg.named exclude_dirs $@ && local exclude_dirs_raw=$REPLY + z.arg.named author $@ + local author=$REPLY + + z.arg.named exclude_exts $@ + local exclude_exts_raw=$REPLY + + z.arg.named exclude_dirs $@ + local exclude_dirs_raw=$REPLY z.git.stats._commit.details.excludes exclude_exts=$exclude_exts_raw exclude_dirs=$exclude_dirs_raw - z.arr.split "$REPLY" && local patterns=($REPLY) + z.arr.split "$REPLY" + local patterns=($REPLY) local exclude_exts_pattern=$patterns[1] local exclude_dirs_pattern=$patterns[2] - local inserted_total=0 && local deleted_total=0 + local inserted_total=0 + local deleted_total=0 local log=$( git log --pretty=tformat: --numstat --author="$author" | grep -v -E "$exclude_exts_pattern|$exclude_dirs_pattern" @@ -86,8 +99,11 @@ z.git.stats._commit.details() { # z.git.stats._commit.sum_lines inserted=1000 deleted=500 # #=> 1500 z.git.stats._commit.sum_lines() { - z.arg.named inserted $@ && local inserted=$REPLY - z.arg.named deleted $@ && local deleted=$REPLY + z.arg.named inserted $@ + local inserted=$REPLY + + z.arg.named deleted $@ + local deleted=$REPLY z.is.null "$inserted" && inserted=0 z.is.null "$deleted" && deleted=0 diff --git a/mod/git/stats/exclude/analysis.zsh b/mod/git/stats/exclude/analysis.zsh index 4130d7d..f6594ae 100644 --- a/mod/git/stats/exclude/analysis.zsh +++ b/mod/git/stats/exclude/analysis.zsh @@ -8,7 +8,8 @@ # example: # z.git.stats._exclude.exts exclude_exts=("md" "txt") #=> ("md" "txt") z.git.stats._exclude.exts() { - z.arg.named exclude_exts $@ && local exts=($REPLY) + z.arg.named exclude_exts $@ + local exts=($REPLY) if z.is.null $REPLY; then exts=( log @@ -29,7 +30,8 @@ z.git.stats._exclude.exts() { # example: # z.git.stats._exclude.dirs exclude_dirs=("docs" "tests") #=> ("docs" "tests") z.git.stats._exclude.dirs() { - z.arg.named exclude_dirs $@ && local dirs=($REPLY) + z.arg.named exclude_dirs $@ + local dirs=($REPLY) if z.is.null $REPLY; then dirs=( node_modules diff --git a/mod/git/stats/process.zsh b/mod/git/stats/process.zsh index 910d911..ead4b2c 100644 --- a/mod/git/stats/process.zsh +++ b/mod/git/stats/process.zsh @@ -23,8 +23,10 @@ z.git.stats() { # example: # z.git.stats._show exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") z.git.stats._show() { - z.git.stats._exclude.exts $@ && local exclude_exts=($REPLY) - z.git.stats._exclude.dirs $@ && local exclude_dirs=($REPLY) + z.git.stats._exclude.exts $@ + local exclude_exts=($REPLY) + z.git.stats._exclude.dirs $@ + local exclude_dirs=($REPLY) z.git.stats._exclude exclude_exts="${exclude_exts[*]}" exclude_dirs="${exclude_dirs[*]}" z.git.stats._author exclude_exts="${exclude_exts[*]}" exclude_dirs="${exclude_dirs[*]}" @@ -40,8 +42,11 @@ z.git.stats._show() { # example: # z.git.stats._exclude exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") z.git.stats._exclude() { - z.arg.named exclude_exts $@ && local exclude_exts=($REPLY) - z.arg.named exclude_dirs $@ && local exclude_dirs=($REPLY) + z.arg.named exclude_exts $@ + local exclude_exts=($REPLY) + + z.arg.named exclude_dirs $@ + local exclude_dirs=($REPLY) z.io.line "exclude_exts: ${exclude_exts[*]}" "exclude_dirs: ${exclude_dirs[*]}" z.io.line @@ -57,8 +62,11 @@ z.git.stats._exclude() { # example: # z.git.stats._author exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") z.git.stats._author() { - z.arg.named exclude_exts $@ && local exclude_exts=$REPLY - z.arg.named exclude_dirs $@ && local exclude_dirs=$REPLY + z.arg.named exclude_exts $@ + local exclude_exts=$REPLY + + z.arg.named exclude_dirs $@ + local exclude_dirs=$REPLY z.git.stats._author.header z.git.stats._author.body exclude_exts="$exclude_exts" exclude_dirs="$exclude_dirs" diff --git a/mod/job/analysis.zsh b/mod/job/analysis.zsh index b613c89..3703dc3 100644 --- a/mod/job/analysis.zsh +++ b/mod/job/analysis.zsh @@ -8,7 +8,8 @@ # example: # z.job.status id=20260623T121530000000000.100.1 z.job.status() { - z.arg.named id "$@" && local id=$REPLY + z.arg.named id "$@" + local id=$REPLY z.is.null "$id" && return 1 z.job.file._path id=$id name=status || return 1 diff --git a/mod/job/collect/process.zsh b/mod/job/collect/process.zsh index d47d42e..bf5160f 100644 --- a/mod/job/collect/process.zsh +++ b/mod/job/collect/process.zsh @@ -7,7 +7,8 @@ # example: # z.job.collect._one dir=/tmp/z/job/123/jobs/job z.job.collect._one() { - z.arg.named dir "$@" && local dir=$REPLY + z.arg.named dir "$@" + local dir=$REPLY z.is.null "$dir" && return 1 z.job.meta._read dir="$dir" || { @@ -62,8 +63,11 @@ z.job.collect._one() { # example: # z.job.collect._callback dir=/tmp/z/job/123/jobs/job status=success z.job.collect._callback() { - z.arg.named dir "$@" && local dir=$REPLY - z.arg.named status "$@" && local job_status=$REPLY + z.arg.named dir "$@" + local dir=$REPLY + + z.arg.named status "$@" + local job_status=$REPLY z.job.meta._read dir="$dir" || return 1 z.file.read path="$dir/exit" diff --git a/mod/job/file/analysis.zsh b/mod/job/file/analysis.zsh index 61eaedb..9be2e8b 100644 --- a/mod/job/file/analysis.zsh +++ b/mod/job/file/analysis.zsh @@ -30,7 +30,8 @@ z.job.file._jobs() { # example: # z.job.file._dir id=20260623T121530000000000.100.1 z.job.file._dir() { - z.arg.named id "$@" && local id=$REPLY + z.arg.named id "$@" + local id=$REPLY z.is.null "$id" && return 1 z.job.file._jobs @@ -47,8 +48,11 @@ z.job.file._dir() { # example: # z.job.file._path id=20260623T121530000000000.100.1 name=status z.job.file._path() { - z.arg.named id "$@" && local id=$REPLY - z.arg.named name "$@" && local name=$REPLY + z.arg.named id "$@" + local id=$REPLY + + z.arg.named name "$@" + local name=$REPLY z.is.null "$id" && return 1 z.is.null "$name" && return 1 diff --git a/mod/job/is/operator.zsh b/mod/job/is/operator.zsh index 57dbb12..e3beb85 100644 --- a/mod/job/is/operator.zsh +++ b/mod/job/is/operator.zsh @@ -7,7 +7,8 @@ # example: # z.job.is.running id=20260623T121530000000000.100.1 z.job.is.running() { - z.arg.named id "$@" && local id=$REPLY + z.arg.named id "$@" + local id=$REPLY z.is.null "$id" && return 1 z.job.status id="$id" >/dev/null || return 1 diff --git a/mod/job/meta/process.zsh b/mod/job/meta/process.zsh index 1f732c0..4c5df0d 100644 --- a/mod/job/meta/process.zsh +++ b/mod/job/meta/process.zsh @@ -12,12 +12,23 @@ # example: # z.job.meta._write id=job name=example command=z.example.run dir=/tmp/job z.job.meta._write() { - z.arg.named id "$@" && local id=$REPLY - z.arg.named name "$@" && local name=$REPLY - z.arg.named command "$@" && local command=$REPLY - z.arg.named on_success "$@" && local on_success=$REPLY - z.arg.named on_failure "$@" && local on_failure=$REPLY - z.arg.named dir "$@" && local dir=$REPLY + z.arg.named id "$@" + local id=$REPLY + + z.arg.named name "$@" + local name=$REPLY + + z.arg.named command "$@" + local command=$REPLY + + z.arg.named on_success "$@" + local on_success=$REPLY + + z.arg.named on_failure "$@" + local on_failure=$REPLY + + z.arg.named dir "$@" + local dir=$REPLY local lines=() lines+=("z_job_id=${(qqq)id}") @@ -42,7 +53,8 @@ z.job.meta._write() { # example: # z.job.meta._read dir=/tmp/z/job/123/jobs/id z.job.meta._read() { - z.arg.named dir "$@" && local dir=$REPLY + z.arg.named dir "$@" + local dir=$REPLY z.is.null "$dir" && return 1 local meta_file="$dir/meta" diff --git a/mod/job/process.zsh b/mod/job/process.zsh index 3e9f4e2..b3cbc5b 100644 --- a/mod/job/process.zsh +++ b/mod/job/process.zsh @@ -10,10 +10,17 @@ # example: # z.job.run name=example command=z.example.build on_success=z.example.load z.job.run() { - z.arg.named name "$@" && local name=$REPLY - z.arg.named command "$@" && local command=$REPLY - z.arg.named on_success "$@" && local on_success=$REPLY - z.arg.named on_failure "$@" && local on_failure=$REPLY + z.arg.named name "$@" + local name=$REPLY + + z.arg.named command "$@" + local command=$REPLY + + z.arg.named on_success "$@" + local on_success=$REPLY + + z.arg.named on_failure "$@" + local on_failure=$REPLY z.job.run._validate \ name="$name" \ @@ -54,7 +61,8 @@ z.job.run() { # example: # z.job.collect z.job.collect() { - z.job.file._jobs && local jobs_dir=$REPLY + z.job.file._jobs + local jobs_dir=$REPLY if z.dir.not.exists "$jobs_dir"; then z.return && return fi @@ -81,10 +89,12 @@ z.job.collect() { # example: # z.job.cancel id=20260623T121530000000000.100.1 z.job.cancel() { - z.arg.named id "$@" && local id=$REPLY + z.arg.named id "$@" + local id=$REPLY z.is.null "$id" && return 1 - z.job.file._dir id="$id" && local dir=$REPLY + z.job.file._dir id="$id" + local dir=$REPLY z.dir.exists "$dir" || return 1 z.job.meta._read dir="$dir" || return 1 diff --git a/mod/job/run/operator.zsh b/mod/job/run/operator.zsh index 29def4b..b89cb4a 100644 --- a/mod/job/run/operator.zsh +++ b/mod/job/run/operator.zsh @@ -10,10 +10,17 @@ # example: # z.job.run._validate name=example command=z.example.build z.job.run._validate() { - z.arg.named name "$@" && local name=$REPLY - z.arg.named command "$@" && local command=$REPLY - z.arg.named on_success "$@" && local on_success=$REPLY - z.arg.named on_failure "$@" && local on_failure=$REPLY + z.arg.named name "$@" + local name=$REPLY + + z.arg.named command "$@" + local command=$REPLY + + z.arg.named on_success "$@" + local on_success=$REPLY + + z.arg.named on_failure "$@" + local on_failure=$REPLY z.is.null "$name" && return 1 z.is.null "$command" && return 1 diff --git a/mod/job/run/process.zsh b/mod/job/run/process.zsh index 2be558f..7786052 100644 --- a/mod/job/run/process.zsh +++ b/mod/job/run/process.zsh @@ -10,19 +10,29 @@ # example: # z.job.run._prepare name=example command=z.example.build z.job.run._prepare() { - z.arg.named name "$@" && local name=$REPLY - z.arg.named command "$@" && local command=$REPLY - z.arg.named on_success "$@" && local on_success=$REPLY - z.arg.named on_failure "$@" && local on_failure=$REPLY + z.arg.named name "$@" + local name=$REPLY + + z.arg.named command "$@" + local command=$REPLY + + z.arg.named on_success "$@" + local on_success=$REPLY + + z.arg.named on_failure "$@" + local on_failure=$REPLY z.is.null "$name" && return 1 z.is.null "$command" && return 1 - z.job.file._jobs && local jobs_dir=$REPLY + z.job.file._jobs + local jobs_dir=$REPLY z.dir.exists "$jobs_dir" || z.dir.make path="$jobs_dir" - z.job.id._generate && local id=$REPLY - z.job.file._dir id="$id" && local dir=$REPLY + z.job.id._generate + local id=$REPLY + z.job.file._dir id="$id" + local dir=$REPLY z.dir.exists "$dir" || z.dir.make path="$dir" z.job.meta._write \ @@ -51,8 +61,11 @@ z.job.run._prepare() { # example: # z.job.run._spawn id=job dir=/tmp/z/job/123/jobs/job z.job.run._spawn() { - z.arg.named id "$@" && local id=$REPLY - z.arg.named dir "$@" && local dir=$REPLY + z.arg.named id "$@" + local id=$REPLY + + z.arg.named dir "$@" + local dir=$REPLY z.is.null "$id" && return 1 z.is.null "$dir" && return 1 @@ -73,8 +86,11 @@ z.job.run._spawn() { # example: # z.job.run._child id=job dir=/tmp/z/job/123/jobs/job z.job.run._child() { - z.arg.named id "$@" && local id=$REPLY - z.arg.named dir "$@" && local dir=$REPLY + z.arg.named id "$@" + local id=$REPLY + + z.arg.named dir "$@" + local dir=$REPLY z.job.meta._read dir="$dir" || return 1 z.file.write path="$dir/status" content=running diff --git a/mod/wtproxy/entry/process.zsh b/mod/wtproxy/entry/process.zsh index 3e4aa6c..e09826a 100644 --- a/mod/wtproxy/entry/process.zsh +++ b/mod/wtproxy/entry/process.zsh @@ -7,7 +7,8 @@ # example: # z.wtproxy._entry.current activate=true z.wtproxy._entry.current() { - z.arg.named activate $@ default=false && local activate=$REPLY + z.arg.named activate $@ default=false + local activate=$REPLY z.git.wt.current.root || return 1 local worktree_path=$REPLY diff --git a/mod/wtproxy/init/config/port/process.zsh b/mod/wtproxy/init/config/port/process.zsh index bdba169..6d6a479 100644 --- a/mod/wtproxy/init/config/port/process.zsh +++ b/mod/wtproxy/init/config/port/process.zsh @@ -8,7 +8,8 @@ # example: # z.wtproxy.init._config.port.value proxy_port_1 proxy_port_1=3000 z.wtproxy.init._config.port.value() { - local key=$1 && shift + local key=$1 + shift z.arg.named $key $@ local value=$REPLY diff --git a/mod/wtproxy/rm/process.zsh b/mod/wtproxy/rm/process.zsh index b8cf8d9..09c69b2 100644 --- a/mod/wtproxy/rm/process.zsh +++ b/mod/wtproxy/rm/process.zsh @@ -7,7 +7,8 @@ # example: # z.wtproxy.rm._current expected_project=project_branch_hash z.wtproxy.rm._current() { - z.arg.named expected_project $@ default="" && local expected_project=$REPLY + z.arg.named expected_project $@ default="" + local expected_project=$REPLY z.git.wt.current.root || return 1 local worktree_path=$REPLY From b5a8d10918791c5cd9c51413397d72690d54bfd9 Mon Sep 17 00:00:00 2001 From: milkeclair Date: Sun, 15 Nov 2026 12:58:11 +0900 Subject: [PATCH 2/5] refactor: remove redundant mod checks and keep completion setup best effort --- mod/completion/function/analysis.zsh | 2 -- mod/completion/process.zsh | 4 ++-- mod/job/analysis.zsh | 2 +- mod/job/file/analysis.zsh | 2 +- mod/job/process.zsh | 2 +- mod/job/run/process.zsh | 7 ++----- mod/wtproxy/config/analysis.zsh | 2 +- mod/wtproxy/port/analysis.zsh | 2 +- test/mod/completion/process_test.zsh | 18 ++++++++++++------ 9 files changed, 21 insertions(+), 20 deletions(-) diff --git a/mod/completion/function/analysis.zsh b/mod/completion/function/analysis.zsh index 973dcea..969ab6d 100644 --- a/mod/completion/function/analysis.zsh +++ b/mod/completion/function/analysis.zsh @@ -10,8 +10,6 @@ z.completion.function._candidates() { local prefix=$1 local function_names=("${z_completion_function_names[@]}") - z.int.is.zero ${#function_names[@]} && return 1 - local candidates=() for function_name in $function_names; do if z.str.start_with "$function_name" "z." && diff --git a/mod/completion/process.zsh b/mod/completion/process.zsh index f684214..1c34f49 100644 --- a/mod/completion/process.zsh +++ b/mod/completion/process.zsh @@ -15,10 +15,10 @@ z.completion.enable() { z.completion.is._interactive || return 0 z.completion.cache.build._names - z.completion.compdef._ignore_private || return 1 + z.completion.compdef._ignore_private z.completion.compdef._register || return 1 autoload -Uz add-zsh-hook - add-zsh-hook zshexit z.completion.cache._cancel || return 1 + add-zsh-hook zshexit z.completion.cache._cancel z.completion.cache._cancel z.job.run \ diff --git a/mod/job/analysis.zsh b/mod/job/analysis.zsh index 3703dc3..64938a1 100644 --- a/mod/job/analysis.zsh +++ b/mod/job/analysis.zsh @@ -12,7 +12,7 @@ z.job.status() { local id=$REPLY z.is.null "$id" && return 1 - z.job.file._path id=$id name=status || return 1 + z.job.file._path id=$id name=status local status_file=$REPLY z.file.exists "$status_file" || return 1 diff --git a/mod/job/file/analysis.zsh b/mod/job/file/analysis.zsh index 9be2e8b..d06e87d 100644 --- a/mod/job/file/analysis.zsh +++ b/mod/job/file/analysis.zsh @@ -57,6 +57,6 @@ z.job.file._path() { z.is.null "$id" && return 1 z.is.null "$name" && return 1 - z.job.file._dir id=$id || return 1 + z.job.file._dir id=$id z.return "$REPLY/$name" } diff --git a/mod/job/process.zsh b/mod/job/process.zsh index b3cbc5b..9cbf438 100644 --- a/mod/job/process.zsh +++ b/mod/job/process.zsh @@ -32,7 +32,7 @@ z.job.run() { name="$name" \ command="$command" \ on_success="$on_success" \ - on_failure="$on_failure" || return 1 + on_failure="$on_failure" local -a prepared=("${REPLY[@]}") local id=$prepared[1] local dir=$prepared[2] diff --git a/mod/job/run/process.zsh b/mod/job/run/process.zsh index 7786052..4bcb7a5 100644 --- a/mod/job/run/process.zsh +++ b/mod/job/run/process.zsh @@ -1,11 +1,11 @@ -# prepare a job directory +# prepare a job directory after argument validation # # $name: job name # $command: child function name # $on_success?: parent success callback function name # $on_failure?: parent failure callback function name # REPLY: job id and job directory -# return: 0|1 +# return: null # # example: # z.job.run._prepare name=example command=z.example.build @@ -22,9 +22,6 @@ z.job.run._prepare() { z.arg.named on_failure "$@" local on_failure=$REPLY - z.is.null "$name" && return 1 - z.is.null "$command" && return 1 - z.job.file._jobs local jobs_dir=$REPLY z.dir.exists "$jobs_dir" || z.dir.make path="$jobs_dir" diff --git a/mod/wtproxy/config/analysis.zsh b/mod/wtproxy/config/analysis.zsh index 65f8048..f053545 100644 --- a/mod/wtproxy/config/analysis.zsh +++ b/mod/wtproxy/config/analysis.zsh @@ -6,7 +6,7 @@ # example: # z.wtproxy._config z.wtproxy._config() { - z.wtproxy._config.values || return 1 + z.wtproxy._config.values local -A config=("${(@)REPLY}") z.wtproxy._config.file.default_project || { diff --git a/mod/wtproxy/port/analysis.zsh b/mod/wtproxy/port/analysis.zsh index 69312f7..aafee38 100644 --- a/mod/wtproxy/port/analysis.zsh +++ b/mod/wtproxy/port/analysis.zsh @@ -26,7 +26,7 @@ z.wtproxy._port.proxies() { z.wtproxy._port.keys.from_config config for port_key in ${(@)REPLY}; do - z.wtproxy._port.worktree.index $port_key || return 1 + z.wtproxy._port.worktree.index $port_key local port_index=$REPLY z.wtproxy._port.proxy.key $port_index local config_key=$REPLY diff --git a/test/mod/completion/process_test.zsh b/test/mod/completion/process_test.zsh index 1e65e8e..8d47b8c 100644 --- a/test/mod/completion/process_test.zsh +++ b/test/mod/completion/process_test.zsh @@ -58,17 +58,23 @@ z.t.describe "z.completion.enable"; { } z.t.context "private除外設定に失敗した場合"; { - z.t.it "jobを起動しない"; { + z.t.it "補完登録とcache jobの起動を続ける"; { + local z_completion_cache_job_id="" + local -a zshexit_functions=() + local -a completion_calls=() z.t.mock name="z.completion.is._interactive" behavior="return 0" z.t.mock name="z.completion.compdef._ignore_private" behavior="return 1" - z.t.mock name="z.completion.compdef._register" behavior="return 0" - z.t.mock name="z.job.run" behavior="z.return job-id" + z.t.mock name="z.completion.compdef._register" behavior='completion_calls+=(register); return 0' + z.t.mock name="z.job.run" behavior='completion_calls+=(job); z.return job-id' z.completion.enable + local result_code=$? + local result_reply=$REPLY - z.t.expect.status.is.false skip_unmock=true - z.t.mock.result name="z.job.run" - z.t.expect.reply "" + z.t.expect "$result_code" 0 skip_unmock=true + z.t.expect "$result_reply" job-id skip_unmock=true + z.t.expect "$completion_calls" "register job" skip_unmock=true + z.t.expect "$zshexit_functions" z.completion.cache._cancel } } From 818692ebf7ad920de19ef63454719c05d639ece7 Mon Sep 17 00:00:00 2001 From: milkeclair Date: Sun, 15 Nov 2026 13:00:46 +0900 Subject: [PATCH 3/5] test: align completion terminal argument capture --- test/mod/completion/complete/terminal.zsh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/mod/completion/complete/terminal.zsh b/test/mod/completion/complete/terminal.zsh index c6365ed..5b40888 100644 --- a/test/mod/completion/complete/terminal.zsh +++ b/test/mod/completion/complete/terminal.zsh @@ -36,8 +36,11 @@ if z.is.eq "$1" initialize; then return 0 fi -z.arg.named input "$@" && local input=$REPLY -z.arg.named setup "$@" && local setup=$REPLY +z.arg.named input "$@" +local input=$REPLY + +z.arg.named setup "$@" +local setup=$REPLY zmodload zsh/zpty || exit 1 zmodload zsh/zselect || exit 1 From 77656caf607d7f8318ad4740e78b2e037825458f Mon Sep 17 00:00:00 2001 From: milkeclair Date: Sun, 15 Nov 2026 13:13:03 +0900 Subject: [PATCH 4/5] fix: preserve established mod capture and declaration style --- mod/completion/cache/build/process.zsh | 3 +- mod/completion/cache/load/process.zsh | 3 +- mod/git/branch/analysis.zsh | 3 +- mod/git/branch/merged/get/process.zsh | 6 ++-- mod/git/commit/arg/is/not/operator.zsh | 3 +- mod/git/commit/msg/process.zsh | 15 +++----- mod/git/commit/process.zsh | 17 +++------ mod/git/commit/tag/is/operator.zsh | 3 +- mod/git/commit/tdd/cycle/is/operator.zsh | 3 +- mod/git/hp/analysis.zsh | 3 +- mod/git/stats/author/process.zsh | 44 +++++++---------------- mod/git/stats/commit/details/process.zsh | 7 ++-- mod/git/stats/commit/map/analysis.zsh | 6 ++-- mod/git/stats/commit/process.zsh | 38 ++++++-------------- mod/git/stats/exclude/analysis.zsh | 6 ++-- mod/git/stats/process.zsh | 20 ++++------- mod/job/analysis.zsh | 3 +- mod/job/collect/process.zsh | 10 ++---- mod/job/file/analysis.zsh | 10 ++---- mod/job/is/operator.zsh | 3 +- mod/job/meta/process.zsh | 26 ++++---------- mod/job/process.zsh | 24 ++++--------- mod/job/run/operator.zsh | 15 +++----- mod/job/run/process.zsh | 38 ++++++-------------- mod/wtproxy/entry/process.zsh | 3 +- mod/wtproxy/init/config/port/process.zsh | 3 +- mod/wtproxy/rm/process.zsh | 3 +- test/mod/completion/complete/terminal.zsh | 7 ++-- 28 files changed, 96 insertions(+), 229 deletions(-) diff --git a/mod/completion/cache/build/process.zsh b/mod/completion/cache/build/process.zsh index c3b1098..a9ae5fe 100644 --- a/mod/completion/cache/build/process.zsh +++ b/mod/completion/cache/build/process.zsh @@ -43,8 +43,7 @@ z.completion.cache.build._docs() { # example: # z.completion.cache.build._result result=/tmp/z/job/result z.completion.cache.build._result() { - z.arg.named result "$@" - local result=$REPLY + z.arg.named result "$@" && local result=$REPLY z.is.null "$result" && return 1 z.completion.cache._build diff --git a/mod/completion/cache/load/process.zsh b/mod/completion/cache/load/process.zsh index 5fccecc..1b2528e 100644 --- a/mod/completion/cache/load/process.zsh +++ b/mod/completion/cache/load/process.zsh @@ -7,8 +7,7 @@ # example: # z.completion.cache.load._result result=/tmp/z/job/result z.completion.cache.load._result() { - z.arg.named result "$@" - local result=$REPLY + z.arg.named result "$@" && local result=$REPLY z.is.null "$result" && return 1 source "$result" diff --git a/mod/git/branch/analysis.zsh b/mod/git/branch/analysis.zsh index e4f51c4..907ff9d 100644 --- a/mod/git/branch/analysis.zsh +++ b/mod/git/branch/analysis.zsh @@ -6,8 +6,7 @@ # example: # z.git.branch.current #=> "main" z.git.branch.current() { - z.git.branch.current._get - local current=$REPLY + z.git.branch.current._get && local current=$REPLY z.io $current } diff --git a/mod/git/branch/merged/get/process.zsh b/mod/git/branch/merged/get/process.zsh index 75d9742..d1358c9 100644 --- a/mod/git/branch/merged/get/process.zsh +++ b/mod/git/branch/merged/get/process.zsh @@ -9,8 +9,7 @@ z.git.branch._merged.get.excludes() { local exclude_branches=(main master develop release) - z.arg.named exclude_branches "$@" - local exclude_arg=$REPLY + z.arg.named exclude_branches "$@" && local exclude_arg=$REPLY if z.is.not.null "$exclude_arg"; then z.arr.split "$exclude_arg" exclude_branches=($REPLY) @@ -28,8 +27,7 @@ z.git.branch._merged.get.excludes() { # example: # z.git.branch._merged.get.remove_symbols "* feature/branch" #=> "feature/branch" z.git.branch._merged.get.remove_symbols() { - z.str.trim "$1" - local trimmed=$REPLY + z.str.trim "$1" && local trimmed=$REPLY if z.str.start_with "$trimmed" "*" || z.str.start_with "$trimmed" "+"; then z.arr.split "$trimmed" z.return $REPLY[2] diff --git a/mod/git/commit/arg/is/not/operator.zsh b/mod/git/commit/arg/is/not/operator.zsh index 500a4f1..3a2a242 100644 --- a/mod/git/commit/arg/is/not/operator.zsh +++ b/mod/git/commit/arg/is/not/operator.zsh @@ -8,8 +8,7 @@ # z.git.commit._arg.is.not.no_ticket -m "commit message" #=> true # z.git.commit._arg.is.not.no_ticket -m "commit message" -nt #=> false z.git.commit._arg.is.not.no_ticket() { - z.arg.named opts $@ - local opts=$REPLY + z.arg.named opts $@ && local opts=$REPLY z.str.is.not.match " $opts " "[[:space:]]-nt[[:space:]]" } diff --git a/mod/git/commit/msg/process.zsh b/mod/git/commit/msg/process.zsh index 91f1175..8d80062 100644 --- a/mod/git/commit/msg/process.zsh +++ b/mod/git/commit/msg/process.zsh @@ -12,17 +12,10 @@ # z.git.commit._msg.build tag="feat" message="add new feature" ticket="TICKET-123" cycle="red" # #=> "feat: #TICKET-123 [red] add new feature" z.git.commit._msg.build() { - z.arg.named tag $@ - local tag=$REPLY - - z.arg.named message $@ - local message=$REPLY - - z.arg.named ticket $@ - local ticket=$REPLY - - z.arg.named cycle $@ - local cycle=$REPLY + z.arg.named tag $@ && local tag=$REPLY + z.arg.named message $@ && local message=$REPLY + z.arg.named ticket $@ && local ticket=$REPLY + z.arg.named cycle $@ && local cycle=$REPLY local commit_message="$tag: " z.is.not.null $ticket && commit_message+="#$ticket " diff --git a/mod/git/commit/process.zsh b/mod/git/commit/process.zsh index a0f3729..7cd701b 100644 --- a/mod/git/commit/process.zsh +++ b/mod/git/commit/process.zsh @@ -61,9 +61,7 @@ z.git.commit() { z.group "extract arguments"; { z.git.commit._arg.extract $@ local -A args=("${(@)REPLY}") - local tag=$args[tag] - local message=$args[message] - local ticket=$args[ticket] + local tag=$args[tag] && local message=$args[message] && local ticket=$args[ticket] z.git.commit._arg.extract.opts "${(@kv)args}" local opts=(${(@)REPLY}) @@ -93,8 +91,7 @@ z.git.commit() { # example: # z.git.commit.tdd red feat "add new feature" TICKET-123 -ca -ae z.git.commit.tdd() { - local cycle=$1 - shift + local cycle=$1 && shift z.git.commit.tdd._cycle.is.valid $cycle || return 1 z.git.commit._arg.is.enough $@ || return 1 @@ -102,9 +99,7 @@ z.git.commit.tdd() { z.group "extract arguments"; { z.git.commit._arg.extract $@ local -A args=("${(@)REPLY}") - local tag=$args[tag] - local message=$args[message] - local ticket=$args[ticket] + local tag=$args[tag] && local message=$args[message] && local ticket=$args[ticket] z.git.commit._arg.extract.opts "${(@kv)args}" local opts=(${(@)REPLY}) @@ -131,8 +126,7 @@ z.git.commit.tdd() { # example: # z.git.commit._with_committer "feat: add new feature" -ca z.git.commit._with_committer() { - local message=$1 - shift + local message=$1 && shift z.git.commit._opts.extract $@ local opts=(${(@)REPLY}) @@ -149,8 +143,7 @@ z.git.commit._with_committer() { # example: # z.git.commit.help z.git.commit.help() { - z.git.commit._tag.list - local tags=$REPLY + z.git.commit._tag.list && local tags=$REPLY z.io.empty z.io indent=1 "Usage:" diff --git a/mod/git/commit/tag/is/operator.zsh b/mod/git/commit/tag/is/operator.zsh index fb4122e..cfa3fbe 100644 --- a/mod/git/commit/tag/is/operator.zsh +++ b/mod/git/commit/tag/is/operator.zsh @@ -8,8 +8,7 @@ # z.git.commit._tag.is.valid "feat" #=> true # z.git.commit._tag.is.valid "invalid_tag" #=> false z.git.commit._tag.is.valid() { - z.git.commit._tag.list - local tag_list="${REPLY[*]}" + z.git.commit._tag.list && local tag_list="${REPLY[*]}" local tag=$1 z.str.split str="$tag_list" delimiter=" " local -a tags=("${(@)REPLY}") diff --git a/mod/git/commit/tdd/cycle/is/operator.zsh b/mod/git/commit/tdd/cycle/is/operator.zsh index d3c6ebe..4d1cb0a 100644 --- a/mod/git/commit/tdd/cycle/is/operator.zsh +++ b/mod/git/commit/tdd/cycle/is/operator.zsh @@ -8,8 +8,7 @@ # z.git.commit.tdd._cycle.is.valid "red" #=> true # z.git.commit.tdd._cycle.is.valid "invalid_cycle" #=> false z.git.commit.tdd._cycle.is.valid() { - z.git.commit.tdd._cycle.list - local cycle_list="${REPLY[*]}" + z.git.commit.tdd._cycle.list && local cycle_list="${REPLY[*]}" local cycle=$1 z.str.split str="$cycle_list" delimiter=" " local -a cycles=("${(@)REPLY}") diff --git a/mod/git/hp/analysis.zsh b/mod/git/hp/analysis.zsh index abcc90e..6b3b30f 100644 --- a/mod/git/hp/analysis.zsh +++ b/mod/git/hp/analysis.zsh @@ -7,8 +7,7 @@ # # if current branch is feature/some-description-123 # z.git._hp.ticket #=> "123" z.git._hp.ticket() { - z.git.branch.current._get - local branch=$REPLY + z.git.branch.current._get && local branch=$REPLY # e.g. feature/some-description-123 => some-description-123 z.str.split str=$branch delimiter="/" diff --git a/mod/git/stats/author/process.zsh b/mod/git/stats/author/process.zsh index bfc55e2..93f480b 100644 --- a/mod/git/stats/author/process.zsh +++ b/mod/git/stats/author/process.zsh @@ -22,13 +22,9 @@ z.git.stats._author.header() { # example: # z.git.stats._author.body exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") z.git.stats._author.body() { - z.arg.named exclude_exts $@ - local exclude_exts=($REPLY) - - z.arg.named exclude_dirs $@ - local exclude_dirs=($REPLY) - z.git.stats._author.names - local authors=($REPLY) + z.arg.named exclude_exts $@ && local exclude_exts=($REPLY) + z.arg.named exclude_dirs $@ && local exclude_dirs=($REPLY) + z.git.stats._author.names && local authors=($REPLY) local commit_map=() z.git.stats._commit.map authors="${authors[*]}" exclude_exts="${exclude_exts[*]}" exclude_dirs="${exclude_dirs[*]}" @@ -72,33 +68,19 @@ z.git.stats._author.body() { # z.git.stats._author.show author="milkeclair" commit_count=100 inserted=1000 deleted=1000 total=2000 # #=> display a table row for milkeclair with her commit stats z.git.stats._author.show() { - z.arg.named author $@ - local author=$REPLY - - z.arg.named commit_count $@ - local commit_count=$REPLY - - z.arg.named inserted $@ - local inserted=$REPLY - - z.arg.named deleted $@ - local deleted=$REPLY - - z.arg.named total $@ - local total=$REPLY + z.arg.named author $@ && local author=$REPLY + z.arg.named commit_count $@ && local commit_count=$REPLY + z.arg.named inserted $@ && local inserted=$REPLY + z.arg.named deleted $@ && local deleted=$REPLY + z.arg.named total $@ && local total=$REPLY z.is.null $author && author="Everyone" - z.str.color red - local red=$REPLY - z.str.color green - local green=$REPLY - z.str.color yellow - local yellow=$REPLY - z.str.color magenta - local magenta=$REPLY - z.str.color reset - local reset=$REPLY + z.str.color red && local red=$REPLY + z.str.color green && local green=$REPLY + z.str.color yellow && local yellow=$REPLY + z.str.color magenta && local magenta=$REPLY + z.str.color reset && local reset=$REPLY # %-20s: ljust 20 for string # %-10d: ljust 10 for digit diff --git a/mod/git/stats/commit/details/process.zsh b/mod/git/stats/commit/details/process.zsh index 8252819..d391589 100644 --- a/mod/git/stats/commit/details/process.zsh +++ b/mod/git/stats/commit/details/process.zsh @@ -9,11 +9,8 @@ # z.git.stats._commit.details.excludes exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") # #=> REPLY="\.(md|txt)$ (docs|tests)/" z.git.stats._commit.details.excludes() { - z.arg.named exclude_exts $@ - local exclude_exts_raw=$REPLY - - z.arg.named exclude_dirs $@ - local exclude_dirs_raw=$REPLY + z.arg.named exclude_exts $@ && local exclude_exts_raw=$REPLY + z.arg.named exclude_dirs $@ && local exclude_dirs_raw=$REPLY if z.is.not.null "$exclude_exts_raw"; then z.str.split str="$exclude_exts_raw" delimiter=" " diff --git a/mod/git/stats/commit/map/analysis.zsh b/mod/git/stats/commit/map/analysis.zsh index d906df9..5d49d9f 100644 --- a/mod/git/stats/commit/map/analysis.zsh +++ b/mod/git/stats/commit/map/analysis.zsh @@ -7,8 +7,7 @@ # example: # z.git.stats._commit.map.split entry="milkeclair:1000 500:50" z.git.stats._commit.map.split() { - z.arg.named entry "$@" - local entry=$REPLY + z.arg.named entry "$@" && local entry=$REPLY z.str.split str="$entry" delimiter=: local parts=($REPLY) @@ -16,8 +15,7 @@ z.git.stats._commit.map.split() { local details=$parts[2] local commit_count=$parts[3] - z.str.split str="$details" delimiter=" " - local lines=($REPLY) + z.str.split str="$details" delimiter=" " && local lines=($REPLY) local inserted=$lines[1] local deleted=$lines[2] z.git.stats._commit.sum_lines inserted=$inserted deleted=$deleted diff --git a/mod/git/stats/commit/process.zsh b/mod/git/stats/commit/process.zsh index 22d438f..539fc93 100644 --- a/mod/git/stats/commit/process.zsh +++ b/mod/git/stats/commit/process.zsh @@ -10,14 +10,9 @@ # z.git.stats._commit.map authors=("Alice" "Bob") exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") # #=> REPLY=("Alice:1000 500:50" "Bob:800 300:40") z.git.stats._commit.map() { - z.arg.named authors $@ - local authors_raw=$REPLY - - z.arg.named exclude_exts $@ - local exclude_exts=($REPLY) - - z.arg.named exclude_dirs $@ - local exclude_dirs=($REPLY) + z.arg.named authors $@ && local authors_raw=$REPLY + z.arg.named exclude_exts $@ && local exclude_exts=($REPLY) + z.arg.named exclude_dirs $@ && local exclude_dirs=($REPLY) local authors=() if z.is.not.null "$authors_raw"; then @@ -31,8 +26,7 @@ z.git.stats._commit.map() { z.git.stats._commit.details author="$author" exclude_exts=$exclude_exts exclude_dirs=$exclude_dirs z.str.split str="$REPLY" delimiter=" " local details=($REPLY) - z.git.stats._commit.count "$author" - local count=$REPLY + z.git.stats._commit.count "$author" && local count=$REPLY if z.int.is.not.zero $count; then local details_str="${details[1]} ${details[2]}" @@ -54,23 +48,16 @@ z.git.stats._commit.map() { # example: # z.git.stats._commit.details author="milkeclair" exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") z.git.stats._commit.details() { - z.arg.named author $@ - local author=$REPLY - - z.arg.named exclude_exts $@ - local exclude_exts_raw=$REPLY - - z.arg.named exclude_dirs $@ - local exclude_dirs_raw=$REPLY + z.arg.named author $@ && local author=$REPLY + z.arg.named exclude_exts $@ && local exclude_exts_raw=$REPLY + z.arg.named exclude_dirs $@ && local exclude_dirs_raw=$REPLY z.git.stats._commit.details.excludes exclude_exts=$exclude_exts_raw exclude_dirs=$exclude_dirs_raw - z.arr.split "$REPLY" - local patterns=($REPLY) + z.arr.split "$REPLY" && local patterns=($REPLY) local exclude_exts_pattern=$patterns[1] local exclude_dirs_pattern=$patterns[2] - local inserted_total=0 - local deleted_total=0 + local inserted_total=0 && local deleted_total=0 local log=$( git log --pretty=tformat: --numstat --author="$author" | grep -v -E "$exclude_exts_pattern|$exclude_dirs_pattern" @@ -99,11 +86,8 @@ z.git.stats._commit.details() { # z.git.stats._commit.sum_lines inserted=1000 deleted=500 # #=> 1500 z.git.stats._commit.sum_lines() { - z.arg.named inserted $@ - local inserted=$REPLY - - z.arg.named deleted $@ - local deleted=$REPLY + z.arg.named inserted $@ && local inserted=$REPLY + z.arg.named deleted $@ && local deleted=$REPLY z.is.null "$inserted" && inserted=0 z.is.null "$deleted" && deleted=0 diff --git a/mod/git/stats/exclude/analysis.zsh b/mod/git/stats/exclude/analysis.zsh index f6594ae..4130d7d 100644 --- a/mod/git/stats/exclude/analysis.zsh +++ b/mod/git/stats/exclude/analysis.zsh @@ -8,8 +8,7 @@ # example: # z.git.stats._exclude.exts exclude_exts=("md" "txt") #=> ("md" "txt") z.git.stats._exclude.exts() { - z.arg.named exclude_exts $@ - local exts=($REPLY) + z.arg.named exclude_exts $@ && local exts=($REPLY) if z.is.null $REPLY; then exts=( log @@ -30,8 +29,7 @@ z.git.stats._exclude.exts() { # example: # z.git.stats._exclude.dirs exclude_dirs=("docs" "tests") #=> ("docs" "tests") z.git.stats._exclude.dirs() { - z.arg.named exclude_dirs $@ - local dirs=($REPLY) + z.arg.named exclude_dirs $@ && local dirs=($REPLY) if z.is.null $REPLY; then dirs=( node_modules diff --git a/mod/git/stats/process.zsh b/mod/git/stats/process.zsh index ead4b2c..910d911 100644 --- a/mod/git/stats/process.zsh +++ b/mod/git/stats/process.zsh @@ -23,10 +23,8 @@ z.git.stats() { # example: # z.git.stats._show exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") z.git.stats._show() { - z.git.stats._exclude.exts $@ - local exclude_exts=($REPLY) - z.git.stats._exclude.dirs $@ - local exclude_dirs=($REPLY) + z.git.stats._exclude.exts $@ && local exclude_exts=($REPLY) + z.git.stats._exclude.dirs $@ && local exclude_dirs=($REPLY) z.git.stats._exclude exclude_exts="${exclude_exts[*]}" exclude_dirs="${exclude_dirs[*]}" z.git.stats._author exclude_exts="${exclude_exts[*]}" exclude_dirs="${exclude_dirs[*]}" @@ -42,11 +40,8 @@ z.git.stats._show() { # example: # z.git.stats._exclude exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") z.git.stats._exclude() { - z.arg.named exclude_exts $@ - local exclude_exts=($REPLY) - - z.arg.named exclude_dirs $@ - local exclude_dirs=($REPLY) + z.arg.named exclude_exts $@ && local exclude_exts=($REPLY) + z.arg.named exclude_dirs $@ && local exclude_dirs=($REPLY) z.io.line "exclude_exts: ${exclude_exts[*]}" "exclude_dirs: ${exclude_dirs[*]}" z.io.line @@ -62,11 +57,8 @@ z.git.stats._exclude() { # example: # z.git.stats._author exclude_exts=("md" "txt") exclude_dirs=("docs" "tests") z.git.stats._author() { - z.arg.named exclude_exts $@ - local exclude_exts=$REPLY - - z.arg.named exclude_dirs $@ - local exclude_dirs=$REPLY + z.arg.named exclude_exts $@ && local exclude_exts=$REPLY + z.arg.named exclude_dirs $@ && local exclude_dirs=$REPLY z.git.stats._author.header z.git.stats._author.body exclude_exts="$exclude_exts" exclude_dirs="$exclude_dirs" diff --git a/mod/job/analysis.zsh b/mod/job/analysis.zsh index 64938a1..9276718 100644 --- a/mod/job/analysis.zsh +++ b/mod/job/analysis.zsh @@ -8,8 +8,7 @@ # example: # z.job.status id=20260623T121530000000000.100.1 z.job.status() { - z.arg.named id "$@" - local id=$REPLY + z.arg.named id "$@" && local id=$REPLY z.is.null "$id" && return 1 z.job.file._path id=$id name=status diff --git a/mod/job/collect/process.zsh b/mod/job/collect/process.zsh index bf5160f..d47d42e 100644 --- a/mod/job/collect/process.zsh +++ b/mod/job/collect/process.zsh @@ -7,8 +7,7 @@ # example: # z.job.collect._one dir=/tmp/z/job/123/jobs/job z.job.collect._one() { - z.arg.named dir "$@" - local dir=$REPLY + z.arg.named dir "$@" && local dir=$REPLY z.is.null "$dir" && return 1 z.job.meta._read dir="$dir" || { @@ -63,11 +62,8 @@ z.job.collect._one() { # example: # z.job.collect._callback dir=/tmp/z/job/123/jobs/job status=success z.job.collect._callback() { - z.arg.named dir "$@" - local dir=$REPLY - - z.arg.named status "$@" - local job_status=$REPLY + z.arg.named dir "$@" && local dir=$REPLY + z.arg.named status "$@" && local job_status=$REPLY z.job.meta._read dir="$dir" || return 1 z.file.read path="$dir/exit" diff --git a/mod/job/file/analysis.zsh b/mod/job/file/analysis.zsh index d06e87d..03c9c83 100644 --- a/mod/job/file/analysis.zsh +++ b/mod/job/file/analysis.zsh @@ -30,8 +30,7 @@ z.job.file._jobs() { # example: # z.job.file._dir id=20260623T121530000000000.100.1 z.job.file._dir() { - z.arg.named id "$@" - local id=$REPLY + z.arg.named id "$@" && local id=$REPLY z.is.null "$id" && return 1 z.job.file._jobs @@ -48,11 +47,8 @@ z.job.file._dir() { # example: # z.job.file._path id=20260623T121530000000000.100.1 name=status z.job.file._path() { - z.arg.named id "$@" - local id=$REPLY - - z.arg.named name "$@" - local name=$REPLY + z.arg.named id "$@" && local id=$REPLY + z.arg.named name "$@" && local name=$REPLY z.is.null "$id" && return 1 z.is.null "$name" && return 1 diff --git a/mod/job/is/operator.zsh b/mod/job/is/operator.zsh index e3beb85..57dbb12 100644 --- a/mod/job/is/operator.zsh +++ b/mod/job/is/operator.zsh @@ -7,8 +7,7 @@ # example: # z.job.is.running id=20260623T121530000000000.100.1 z.job.is.running() { - z.arg.named id "$@" - local id=$REPLY + z.arg.named id "$@" && local id=$REPLY z.is.null "$id" && return 1 z.job.status id="$id" >/dev/null || return 1 diff --git a/mod/job/meta/process.zsh b/mod/job/meta/process.zsh index 4c5df0d..1f732c0 100644 --- a/mod/job/meta/process.zsh +++ b/mod/job/meta/process.zsh @@ -12,23 +12,12 @@ # example: # z.job.meta._write id=job name=example command=z.example.run dir=/tmp/job z.job.meta._write() { - z.arg.named id "$@" - local id=$REPLY - - z.arg.named name "$@" - local name=$REPLY - - z.arg.named command "$@" - local command=$REPLY - - z.arg.named on_success "$@" - local on_success=$REPLY - - z.arg.named on_failure "$@" - local on_failure=$REPLY - - z.arg.named dir "$@" - local dir=$REPLY + z.arg.named id "$@" && local id=$REPLY + z.arg.named name "$@" && local name=$REPLY + z.arg.named command "$@" && local command=$REPLY + z.arg.named on_success "$@" && local on_success=$REPLY + z.arg.named on_failure "$@" && local on_failure=$REPLY + z.arg.named dir "$@" && local dir=$REPLY local lines=() lines+=("z_job_id=${(qqq)id}") @@ -53,8 +42,7 @@ z.job.meta._write() { # example: # z.job.meta._read dir=/tmp/z/job/123/jobs/id z.job.meta._read() { - z.arg.named dir "$@" - local dir=$REPLY + z.arg.named dir "$@" && local dir=$REPLY z.is.null "$dir" && return 1 local meta_file="$dir/meta" diff --git a/mod/job/process.zsh b/mod/job/process.zsh index 9cbf438..98f0e30 100644 --- a/mod/job/process.zsh +++ b/mod/job/process.zsh @@ -10,17 +10,10 @@ # example: # z.job.run name=example command=z.example.build on_success=z.example.load z.job.run() { - z.arg.named name "$@" - local name=$REPLY - - z.arg.named command "$@" - local command=$REPLY - - z.arg.named on_success "$@" - local on_success=$REPLY - - z.arg.named on_failure "$@" - local on_failure=$REPLY + z.arg.named name "$@" && local name=$REPLY + z.arg.named command "$@" && local command=$REPLY + z.arg.named on_success "$@" && local on_success=$REPLY + z.arg.named on_failure "$@" && local on_failure=$REPLY z.job.run._validate \ name="$name" \ @@ -61,8 +54,7 @@ z.job.run() { # example: # z.job.collect z.job.collect() { - z.job.file._jobs - local jobs_dir=$REPLY + z.job.file._jobs && local jobs_dir=$REPLY if z.dir.not.exists "$jobs_dir"; then z.return && return fi @@ -89,12 +81,10 @@ z.job.collect() { # example: # z.job.cancel id=20260623T121530000000000.100.1 z.job.cancel() { - z.arg.named id "$@" - local id=$REPLY + z.arg.named id "$@" && local id=$REPLY z.is.null "$id" && return 1 - z.job.file._dir id="$id" - local dir=$REPLY + z.job.file._dir id="$id" && local dir=$REPLY z.dir.exists "$dir" || return 1 z.job.meta._read dir="$dir" || return 1 diff --git a/mod/job/run/operator.zsh b/mod/job/run/operator.zsh index b89cb4a..29def4b 100644 --- a/mod/job/run/operator.zsh +++ b/mod/job/run/operator.zsh @@ -10,17 +10,10 @@ # example: # z.job.run._validate name=example command=z.example.build z.job.run._validate() { - z.arg.named name "$@" - local name=$REPLY - - z.arg.named command "$@" - local command=$REPLY - - z.arg.named on_success "$@" - local on_success=$REPLY - - z.arg.named on_failure "$@" - local on_failure=$REPLY + z.arg.named name "$@" && local name=$REPLY + z.arg.named command "$@" && local command=$REPLY + z.arg.named on_success "$@" && local on_success=$REPLY + z.arg.named on_failure "$@" && local on_failure=$REPLY z.is.null "$name" && return 1 z.is.null "$command" && return 1 diff --git a/mod/job/run/process.zsh b/mod/job/run/process.zsh index 4bcb7a5..478d87e 100644 --- a/mod/job/run/process.zsh +++ b/mod/job/run/process.zsh @@ -10,26 +10,16 @@ # example: # z.job.run._prepare name=example command=z.example.build z.job.run._prepare() { - z.arg.named name "$@" - local name=$REPLY + z.arg.named name "$@" && local name=$REPLY + z.arg.named command "$@" && local command=$REPLY + z.arg.named on_success "$@" && local on_success=$REPLY + z.arg.named on_failure "$@" && local on_failure=$REPLY - z.arg.named command "$@" - local command=$REPLY - - z.arg.named on_success "$@" - local on_success=$REPLY - - z.arg.named on_failure "$@" - local on_failure=$REPLY - - z.job.file._jobs - local jobs_dir=$REPLY + z.job.file._jobs && local jobs_dir=$REPLY z.dir.exists "$jobs_dir" || z.dir.make path="$jobs_dir" - z.job.id._generate - local id=$REPLY - z.job.file._dir id="$id" - local dir=$REPLY + z.job.id._generate && local id=$REPLY + z.job.file._dir id="$id" && local dir=$REPLY z.dir.exists "$dir" || z.dir.make path="$dir" z.job.meta._write \ @@ -58,11 +48,8 @@ z.job.run._prepare() { # example: # z.job.run._spawn id=job dir=/tmp/z/job/123/jobs/job z.job.run._spawn() { - z.arg.named id "$@" - local id=$REPLY - - z.arg.named dir "$@" - local dir=$REPLY + z.arg.named id "$@" && local id=$REPLY + z.arg.named dir "$@" && local dir=$REPLY z.is.null "$id" && return 1 z.is.null "$dir" && return 1 @@ -83,11 +70,8 @@ z.job.run._spawn() { # example: # z.job.run._child id=job dir=/tmp/z/job/123/jobs/job z.job.run._child() { - z.arg.named id "$@" - local id=$REPLY - - z.arg.named dir "$@" - local dir=$REPLY + z.arg.named id "$@" && local id=$REPLY + z.arg.named dir "$@" && local dir=$REPLY z.job.meta._read dir="$dir" || return 1 z.file.write path="$dir/status" content=running diff --git a/mod/wtproxy/entry/process.zsh b/mod/wtproxy/entry/process.zsh index e09826a..3e4aa6c 100644 --- a/mod/wtproxy/entry/process.zsh +++ b/mod/wtproxy/entry/process.zsh @@ -7,8 +7,7 @@ # example: # z.wtproxy._entry.current activate=true z.wtproxy._entry.current() { - z.arg.named activate $@ default=false - local activate=$REPLY + z.arg.named activate $@ default=false && local activate=$REPLY z.git.wt.current.root || return 1 local worktree_path=$REPLY diff --git a/mod/wtproxy/init/config/port/process.zsh b/mod/wtproxy/init/config/port/process.zsh index 6d6a479..bdba169 100644 --- a/mod/wtproxy/init/config/port/process.zsh +++ b/mod/wtproxy/init/config/port/process.zsh @@ -8,8 +8,7 @@ # example: # z.wtproxy.init._config.port.value proxy_port_1 proxy_port_1=3000 z.wtproxy.init._config.port.value() { - local key=$1 - shift + local key=$1 && shift z.arg.named $key $@ local value=$REPLY diff --git a/mod/wtproxy/rm/process.zsh b/mod/wtproxy/rm/process.zsh index 09c69b2..b8cf8d9 100644 --- a/mod/wtproxy/rm/process.zsh +++ b/mod/wtproxy/rm/process.zsh @@ -7,8 +7,7 @@ # example: # z.wtproxy.rm._current expected_project=project_branch_hash z.wtproxy.rm._current() { - z.arg.named expected_project $@ default="" - local expected_project=$REPLY + z.arg.named expected_project $@ default="" && local expected_project=$REPLY z.git.wt.current.root || return 1 local worktree_path=$REPLY diff --git a/test/mod/completion/complete/terminal.zsh b/test/mod/completion/complete/terminal.zsh index 5b40888..c6365ed 100644 --- a/test/mod/completion/complete/terminal.zsh +++ b/test/mod/completion/complete/terminal.zsh @@ -36,11 +36,8 @@ if z.is.eq "$1" initialize; then return 0 fi -z.arg.named input "$@" -local input=$REPLY - -z.arg.named setup "$@" -local setup=$REPLY +z.arg.named input "$@" && local input=$REPLY +z.arg.named setup "$@" && local setup=$REPLY zmodload zsh/zpty || exit 1 zmodload zsh/zselect || exit 1 From 859ac494b5bc82c0e26c6ab0a06d90636c341234 Mon Sep 17 00:00:00 2001 From: milkeclair Date: Sun, 15 Nov 2026 13:27:03 +0900 Subject: [PATCH 5/5] refactor: rely on process query results and verify cancellation contract --- mod/wtproxy/proxy/is/operator.zsh | 3 +-- test/mod/completion/cache/process_test.zsh | 15 +++++++++++++++ test/mod/wtproxy/proxy/is/operator_test.zsh | 11 +++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/mod/wtproxy/proxy/is/operator.zsh b/mod/wtproxy/proxy/is/operator.zsh index 0490ea3..bb7da2f 100644 --- a/mod/wtproxy/proxy/is/operator.zsh +++ b/mod/wtproxy/proxy/is/operator.zsh @@ -31,7 +31,6 @@ z.wtproxy._proxy.is.pid() { z.is.null "$pid" && return 1 z.io.null kill -0 "$pid" || return 1 - local command_line - command_line=$(ps -p "$pid" -o command= 2>/dev/null) || return 1 + local command_line=$(ps -p "$pid" -o command= 2>/dev/null) z.str.includes "$command_line" "z.wtproxy.start._serve" } diff --git a/test/mod/completion/cache/process_test.zsh b/test/mod/completion/cache/process_test.zsh index 99759c9..36a6221 100644 --- a/test/mod/completion/cache/process_test.zsh +++ b/test/mod/completion/cache/process_test.zsh @@ -81,6 +81,21 @@ z.t.describe "z.completion.cache._cancel"; { } } + z.t.context "jobの取消に失敗した場合"; { + z.t.it "補完側のIDを破棄して成功する"; { + local z_completion_cache_job_id=cache-job + z.t.mock name="z.job.status" behavior="z.return running" + z.t.mock name="z.job.cancel" behavior="return 1" + + z.completion.cache._cancel + local result_code=$? + local remaining_id=$z_completion_cache_job_id + + z.t.expect "$result_code" 0 + z.t.expect.is.null "$remaining_id" + } + } + z.t.context "補完jobがない場合"; { z.t.it "他のjobに触れず成功する"; { local z_completion_cache_job_id="" diff --git a/test/mod/wtproxy/proxy/is/operator_test.zsh b/test/mod/wtproxy/proxy/is/operator_test.zsh index f43260e..8b0816a 100644 --- a/test/mod/wtproxy/proxy/is/operator_test.zsh +++ b/test/mod/wtproxy/proxy/is/operator_test.zsh @@ -38,4 +38,15 @@ z.t.describe "z.wtproxy._proxy.is.pid"; { z.t.expect.status.is.false } } + + z.t.context "pid確認後にprocessが終了した場合"; { + z.t.it "commandを取得できないためfalseを返す"; { + z.t.mock name="kill" behavior="return 0" + z.t.mock name="ps" behavior="return 1" + + z.wtproxy._proxy.is.pid 12345 + + z.t.expect.status.is.false + } + } }