Skip to content

fix(load): strip the deferred atinit marker on both branches - #507

Merged
ss-o merged 1 commit into
nextfrom
bug-445
Sep 3, 2026
Merged

fix(load): strip the deferred atinit marker on both branches#507
ss-o merged 1 commit into
nextfrom
bug-445

Conversation

@ss-o

@ss-o ss-o commented Sep 3, 2026

Copy link
Copy Markdown
Member

Fixes the reported defect and a second one of the same kind, found next to it.

Two branches, two defects

atinit'!...' defers the hook, and the ! has to be stripped before the body is evaluated. Two branches strip it, and each was wrong in a different way.

The nocd branch of the source path, reported in #445, stripped 1 instead of !:

eval "${ICE[atinit]#1}"

The body then ran as a command named !typeset.

The command branch put the strip inside the subscript:

eval "${ICE[atinit#!]}"

That looks up an ICE key named atinit#!, finds nothing, and evaluates the empty string:

zsh -fc 'typeset -A ICE=( atinit "!print ran" )
         print "[${ICE[atinit#!]}]"   # []
         print "[${ICE[atinit]#!}]"'  # [print ran]

This one is silent: no error, no hook, and the load reports success. It was not in the report, and it affects as"command" plug-ins without nocd, which is the ordinary case for that branch.

Reproduced

CASE as-command atinit-bang:   MARK_CMD=unset     (no diagnostic at all)
CASE normal+nocd atinit-bang:  MARK_NORM=unset    ((eval):1: command not found: !typeset)

Both sites now read ${ICE[atinit]#!}, matching the two other strips in the file.

Test

tests/atinit-deferred-marker.zsh loads an as"command" plug-in without nocd and a normal plug-in with nocd, each with a deferred atinit that sets a marker, then asserts both markers.

Each defect was reintroduced separately and the matching assertion observed failing:

as"command" deferred atinit did not run: unset      # subscript form restored
nocd deferred atinit did not run: unset             # strip-1 restored

Registered in zsh-n.yml, both path filters and a job. Full suite 24/24.

Note on impact

The silent branch is the more serious of the two. A configuration relying on a deferred atinit hook in an as"command" plug-in has been quietly skipping it, with the load reporting success, so the failure surfaces later as unexplained missing state rather than as an error at load time.

Closes #445

`atinit'!...'` defers the hook, and the `!' has to be stripped before the body
is evaluated. Two branches strip it and each had its own defect.

The nocd branch of the source path stripped `1' instead of `!':

    eval "${ICE[atinit]#1}"

so the body ran as a command named `!typeset', reported by #445.

The command branch put the strip inside the subscript:

    eval "${ICE[atinit#!]}"

which looks up an ICE key named `atinit#!', finds nothing, and evaluates the
empty string. That one is silent: no error, no hook, and the load reports
success. It was not in the report and affects `as"command"' plug-ins without
nocd, which is the ordinary case for that branch.

Reproduced against the previous source:

    CASE as-command atinit-bang:  MARK_CMD=unset      (no diagnostic at all)
    CASE normal+nocd atinit-bang: MARK_NORM=unset     ((eval):1: command not found: !typeset)

Both now read ${ICE[atinit]#!}, matching the other two sites.

tests/atinit-deferred-marker.zsh loads an `as"command"' plug-in without nocd and
a normal plug-in with nocd, each with a deferred atinit that sets a marker, and
asserts both markers. Each defect was reintroduced separately and the matching
assertion observed failing.

Closes #445
@ss-o
ss-o requested a review from a team as a code owner September 3, 2026 02:59
@ss-o
ss-o merged commit 5a76f8a into next Sep 3, 2026
89 checks passed
@ss-o
ss-o deleted the bug-445 branch September 3, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant