Repository navigation
fix: niubash #106/#107/#108 regressions + restore #103 array fix lost in rescue merge - #111
Merged
Merged
Conversation
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
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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\rat line-split time (main lines + heredoc bodies), so\r\nis a line terminator like v1.1.1 did. A lone\rnot followed by\nis still ordinary word text, preserving the GNU-fidelity case (set ""<CR>→$1= bare CR) that motivated the v1.1.2 change.if/then/fiexecuted as external commands; CRLF heredoc delimiters never matching; the shipped 100%-CRLF oh-my-niu bundle flooding the console at startup.2.
-cfollows GNU "first non-option argument" (niubash #107)c8da947d—-cno longer binds the immediately following argv. Options after-ckeep being parsed; the first non-option argument is the command string; the rest of argv becomes$0/$1/....bash -cwith nothing left keeps GNU'soption requires an argument(rc 2).bash -c -l 'echo hi'→hi;bash -c→ rc 2;$0/$1mapping unchanged.shell -c -l <script>invokers (AI coding agents, login wrappers).3.
typeoutput is capture-aware (niubash #108)e240abb5— everytypeinvocation routes through the buffered writer (execute_type_redirected); the old gate on explicit output redirects missed command substitution, soA=$(type -t ls)printedfileto the process stdout and assigned an empty string. Raw-stdoutexecute_typeand the non-io disabled-builtin wrapper are removed (dead code);enable -n typeand explicit redirects keep working.4. Restore the #103 array quote-carrier fix (lost in PR #110)
ba2e7c19— therescue/local-master-batchmerge landed pre-fix content forsrc/executor/arrays.rsandsrc/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 inquote_array_value/quote_assoc_display_key(GNUsh_double_quote) and the quote-removal → carrier-restore → storage-unquote order inappend_array_value. Reapplies both;assignment_quote_roundtrip_regressions(9/9) green again.Tests
tests/issue106_107_108_regressions.rs: 10 CLI-level tests (CRLF compound/heredoc/lone-CR,-c -l/--posix/ usage-error /$0,$1,type -tcapture for file+builtin+redirect).cli_testsenvironment failures (argv0 absolute-path + PUA-marker leakage; identical set fails on the unmodified baseline; CI Linux is green).