Skip to content

niugit wrapper runs command substitution on commit -m message text (breaks verbatim messages) #3

Closed

Description

@caomengxuan666

Bug: the niugit wrapper expands commit -m messages (command substitution on the message)

Discovered today by an agent composing a commit whose message contained backticks and ${(kv)} (zsh-flavored text quoted verbatim from an asset under review): the wrapper executed command substitution on the -m message text, so the first commit failed and backtick content was replaced by executed output.

Repro (any repo):

niugit commit -m 'docs: note `uname -r` and ${HOME} handling'
# observed: backticks/substitutions executed or commit aborted; message bytes not preserved verbatim

GNU git commit -m treats the argument as literal bytes, full stop. A wrapper that re-parses or re-evaluates the message breaks every commit whose message quotes shell syntax — which for THIS project is often (commit messages quoting bash snippets are routine in rubash/niubash).

Workaround used: git commit -F <file> (message read from file survives intact).

Expected: pass -m payloads through to real git byte-exactly (append to argv, never re-parse); if the wrapper must inspect messages, do it without evaluation.

Found in: C:/Users/cmx/AppData/Local/Programs/Niubash/winuxcmd/opt/niugit/git.exe (wrapper shipped with the product, 2026-10 build).

Activity

  1. caomengxuan666 commented on Oct 12, 2026

    @caomengxuan666
    MemberAuthor

    Root-cause analysis (full-stack differential audit)

    We reproduced the report scenario through every layer of the product stack and
    could not reproduce command substitution at any binary layer:

    layer commit -m 'docs: note uname -r and ${HOME} handling' (single-quoted)
    niubash sh / niu -c / script file POSIX-correct: single quotes protect backticks, ${}, $()
    usr/bin/git.exe (wpm multicall link) passes message bytes verbatim
    opt/niugit/git.exe (launcher) passes message bytes verbatim
    opt/niugit/mingw64/bin/git.exe (real) passes message bytes verbatim

    In every case the stored commit object byte-matches the intended message
    (docs: note \uname -r` and ${HOME} handling). None of these components evaluate anything — the launcher is a CreateProcessWforwarder and git never runs a shell over-m`.

    What does reproduce the reported symptoms exactly

    Double-quoting at the call site — standard POSIX shell semantics, identical
    under niu, Git Bash and GNU bash on Linux:

    $ git commit -m "docs: note `uname -r` and ${HOME} handling"
    niu: line 1: ${(kv)...}: bad substitution        # <- first commit FAILS (matches report)
    # and in the non-zsh variant the backticks execute:
    $ echo "A`uname -s`B"
    AMSYS_NT-10.0-19045B                             # <- backtick content replaced by output
    

    The reported failure ("first commit failed and backtick content was
    replaced by executed output") is precisely the double-quoted signature: the
    backticks ran, and a zsh-flavored ${(...)} raised bad substitution. The
    tooling that composed the original commit almost certainly interpolated the
    message into a double-quoted command string. -F <file> "working" is
    consistent with this: it sidesteps shell quoting entirely.

    Recommendation: re-scope this issue to "agent tooling must compose -m
    payloads as single-quoted argv elements (or use -F)"; the wrapper itself is
    byte-transparent for message text.

    Real wrapper-side message-fidelity defects found during the audit

    While differential-testing the stack we found two actual wrapper defects
    that DO rewrite messages silently (filed separately, release-blocking fixes
    proposed):

    Fixes for both are coming on a branch near you.

  2. caomengxuan666 commented on Oct 12, 2026

    @caomengxuan666
    MemberAuthor

    Closing per the full-stack differential audit (see evidence comment above): the wrapper never performs command substitution - single-quoted messages survive all four layers byte-exactly. The original symptom was caller-side double quoting (POSIX shell semantics, identical in GNU bash). Agent tooling guideline: single-quote -m payloads or use -F. The REAL wrapper defects found by the audit are #4/#5, fixed by #6.

  3. added
    bug
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions