Skip to content

fix: niubash #106/#107/#108 regressions + restore #103 array fix lost in rescue merge - #111

Merged
caomengxuan666 merged 4 commits into
masterfrom
feat/issue106-108-fixes
Sep 16, 2026
Merged

caomengxuan666 merged 4 commits into
masterfrom
feat/issue106-108-fixes

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Four fixes driving niubash issues #106, #107, #108, plus a regression introduced by the PR #110 rescue merge.

1. CRLF scripts parse again (niubash #106)

  • 3ce18728 — lexer: strip a trailing \r at line-split time (main lines + heredoc bodies), so \r\n is a line terminator like v1.1.1 did. A lone \r not followed by \n is still ordinary word text, preserving the GNU-fidelity case (set ""<CR> → $1 = bare CR) that motivated the v1.1.2 change.
  • Fixes: CRLF if/then/fi executed as external commands; CRLF heredoc delimiters never matching; the shipped 100%-CRLF oh-my-niu bundle flooding the console at startup.

2. -c follows GNU "first non-option argument" (niubash #107)

  • c8da947d — -c no longer binds the immediately following argv. Options after -c keep being parsed; the first non-option argument is the command string; the rest of argv becomes $0/$1/.... bash -c with nothing left keeps GNU's option requires an argument (rc 2).
  • Verified against GNU bash 5.3.0(1) (WSL oracle): bash -c -l 'echo hi' → hi; bash -c → rc 2; $0/$1 mapping unchanged.
  • Unblocks shell -c -l <script> invokers (AI coding agents, login wrappers).

3. type output is capture-aware (niubash #108)

  • e240abb5 — every type invocation routes through the buffered writer (execute_type_redirected); the old gate on explicit output redirects missed command substitution, so A=$(type -t ls) printed file to the process stdout and assigned an empty string. Raw-stdout execute_type and the non-io disabled-builtin wrapper are removed (dead code); enable -n type and explicit redirects keep working.

4. Restore the #103 array quote-carrier fix (lost in PR #110)

  • ba2e7c19 — the rescue/local-master-batch merge landed pre-fix content for src/executor/arrays.rs and src/executor/arrays/storage.rs, silently reverting the array half of PR fix(assignment): restore \x18 escaped-quote carrier in quoted-assignment fast path (niubash #103) #108 (742a544): single-backslash " escaping in quote_array_value / quote_assoc_display_key (GNU sh_double_quote) and the quote-removal → carrier-restore → storage-unquote order in append_array_value. Reapplies both; assignment_quote_roundtrip_regressions (9/9) green again.

Tests

  • New tests/issue106_107_108_regressions.rs: 10 CLI-level tests (CRLF compound/heredoc/lone-CR, -c -l / --posix / usage-error / $0,$1, type -t capture for file+builtin+redirect).
  • Full suite on Windows: all targets green except the pre-existing 72 cli_tests environment failures (argv0 absolute-path + PUA-marker leakage; identical set fails on the unmodified baseline; CI Linux is green).

The v1.1.2 line-reader rework kept '\r' as ordinary word text to match
GNU bash on Unix, which regressed CRLF scripts: if/then/fi were executed
as external commands and the shipped 100%-CRLF oh-my-niu bundle flooded
the terminal with errors on interactive startup. Strip a trailing '\r' at
line-split time (main lines and heredoc bodies) so '\r\n' acts as a line
terminator; a lone '\r' not followed by
'\n' is still preserved as word text, keeping the GNU-fidelity case
(`set ""<CR>` makes $1 a bare CR) intact.
…niubash #107)

GNU shell.c: commands are read from the first non-option argument after
-c. The old parser bound the immediately following argv, so the common
`shell -c -l '<script>'` invocation (AI agents, login wrappers) executed
the literal -l as a command (127) and dropped the script. -c now only
marks that a command string is owed; option parsing continues and the
first bare argument becomes the command string, with the remaining argv
as $0/$1/... `bash -c` with nothing left keeps GNU's usage error (rc 2).
…niubash #108)

The type dispatch only used the buffered path when the command carried an
explicit output redirect. Command substitution is not an explicit
redirect, so `$(type -t ls)` printed `file` to the process stdout and
assigned an empty string. The raw-stdout execute_type and the non-io
disabled-builtin wrapper are removed; execute_type_with_io already
handles `enable -n` state and explicit redirections.
… merge

PR #108 (742a544) fixed quote_array_value / quote_assoc_display_key to
escape '"' with a single backslash (GNU sh_double_quote) and reordered
append_array_value to quote-removal -> carrier restore -> storage
unquote. The rescue/local-master-batch merge (PR #110) landed
pre-fix content for these files, silently reverting the array side of
#103: x=(q\"q) stored qq again and $'a"b' handling regressed.
Reapplies both halves and adds cli-level regression tests for
niubash #106/#107/#108.
@caomengxuan666
caomengxuan666 merged commit 82b0f6f into master Sep 16, 2026
3 checks passed
caomengxuan666 added a commit that referenced this pull request Sep 16, 2026
…WIP) over #111

Content reconciled from the offline local master (30d42e61, based on 9ac6170)
plus its uncommitted gnu-compat WIP, three-way merged over the PR #111 merge
(82b0f6f). Overlapping files (arrays.rs, arrays/storage.rs, lexer/mod.rs)
carry BOTH sides: the #103/#109 quote-carrier handling and the local
intl/array/trap batch. Leftover [DEBUG] eprintln instrumentation from the WIP
was stripped before landing.

Highlights:
- intl: nested same-shell script output ordering, IFS isolation,
  /usr/bin/printf fixture (30d42e61)
- lexer/executor batch: ANSI-C carrier handling, assignment expansion,
  parameter decode, conditional patterns, prompt expansion,
  temporary assignments, printf escape/path builtins, shell options
- docs: COMPATIBILITY-STATUS ledger (43 zero-diff caliber), README refresh

Full release test suite green on the merged tree; gnu-compat run-83 check
PASS=34 / DIFF=48 / TIMEOUT=1 (unchanged caliber).
@caomengxuan666
caomengxuan666 deleted the feat/issue106-108-fixes branch September 24, 2026 23:47
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