Skip to content

[bug] export -f serialization strips quotes, leaks internal markers #1029

Closed

Description

@caomengxuan666

[bug] export -f serialization strips quotes, leaks internal markers — every quoted exported function corrupts in children (HIGH)

niu re-serializes the parsed AST into BASH_FUNC_name%% without re-quoting. printenv 'BASH_FUNC_q%%' | od -c for q() { echo "$1"; echo "$@"; echo "a b"; echo '$single'; x="a b"; }:

  • GNU: () { echo "$1";\n … x="a b" … }
  • niu: () {\n echo $1;\n echo $@;\n echo a b;\n echo \037single;\n x=a b;\n echo $x\023\n} — all " gone, '…' → \037… with no closer, trailing \023.
q() { x="a  b"; echo "[$x]"; }; export -f q; bash -c 'q'
# bash parent:  [a  b], rc=0
# niu parent:   environment: line 1: b: command not found + [], rc=0
c() { for i in "$@"; do echo "arg:[$i]"; done; }; export -f c; bash -c 'c "a b" d'
# bash parent:  arg:[a b] / arg:[d]
# niu parent:   arg:[a] / arg:[b] / arg:[d]   ("$@" became $@)

Single quotes round-trip niu→niu via internal markers, but leak raw \037 into real bash children (s() { echo '$HOME'; } → child prints \037HOME). Only safe case: no quotes at all. Direction bash→niu imports GNU encoding correctly. Silent corruption — high severity.

Env: niubash 1.4.4 / rubash engine (master ~2026-10), GNU bash 5.3.20 aarch64-linux-android as oracle.

Activity

  1. github-actions commented on Oct 22, 2026

    @github-actions
    Contributor

    欢迎!这是你在本仓库的第一个 ISSUE 🎉 维护者会尽快跟进;报 bug 请附 rubash --version、系统平台与最小复现脚本。

  2. added
    bug
    gnu-baseline
    area:expansion
    family:M2
    P1-high
    on Oct 22, 2026
  3. caomengxuan666 commented on Oct 23, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by #1181 (2026-10-22/23 bulk GNU-parity wave): landed as a dedicated commit referencing this issue, covered by the audit differential suite (tests/fixtures/audit/), and re-verified byte-for-byte against a GNU bash 5.3.20 oracle; master CI (ff1a555) runs the suite green.

    Closing now to restore the linkage: GitHub's closing-reference parser only honored the first entry of #1181's long Fixes list, so this stayed open after the fix landed. If anything still reproduces on current master, reopen with a transcript and it returns to the fix queue.

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

    P1-higharea:expansionbugfamily:M2gnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions