You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
failglob abort scope: GNU abandons the rest of the line, niu only the failing command (one extra statement runs after the error) #753
After a failglob expansion error, the two shells resume in different places. GNU aborts the remainder of the current line / list; niu aborts only the failing command when that command is a compound, and the rest of the line still runs.
Distinct from #726, which is about the diagnostic bypassing a redirection. This is about control flow after the error.
Repro
shopt -s failglob
echo"case1-start"
( set -- /no/such/*.zzz;echo"case1-inside" );echo"case1-rc=$?"echo"case2-start"
{ set -- /no/such/*.zzz;echo"case2-inside"; };echo"case2-rc=$?"echo"case3-start"set -- /no/such/*.zzz;echo"case3-rc=$?"echo"END"
stdout, no redirections so nothing is hidden:
lines printed
GNU bash
case1-start, case1-rc=1, case2-start, case3-start, END
niu / rubash
case1-start, case1-rc=1, case2-start, case2-rc=1, case3-start, END
Diff is exactly one extra line: niu prints case2-rc=1; GNU never reaches that echo.
Reading:
case1 (subshell): both abort the group and both report rc=1 → same.
case2 (brace group): GNU abandons the rest of that line, so the echo after the ; never runs. niu only abandons the group, runs the echo, and reports 1.
case3 (simple command): both abandon the rest of the line → same.
So the divergence is specific to the failure being inside a compound command: GNU treats the expansion error as aborting the enclosing list, niu treats it as aborting only that command.
Why it matters
A script that relies on "the line after a failed glob does not run" will execute one more statement under niu — and that statement typically inspects $? or does the next step. Silent extra execution after an error is the same class as the other members of this family.
Method
LF script file; niu (installed 1.4.0) and WSL GNU bash 5.3.0; stdout and stderr captured to separate files (an earlier attempt with 2>/dev/null on the compound obscured the difference and produced a misleading line count); no other redirections.
Fixed in c5eb976 (fix(executor): a failglob error abandons the rest of the logical line (#753)).
Root cause
The failglob path raised Err(ExecuteError::ExpansionFailure) and set command_expansion_failed, but that error was swallowed by the compound-command boundary: a brace group, if body, case arm, etc. consumed the failure and returned to the enclosing list, which then kept executing the rest of the logical line. The simple-command path already discarded the line (that is why case3 matched); only compounds leaked.
Fix
A new class flag evalerror_failglob_pending mirrors the existing evalerror_subscript_pending discipline: armed at every failglob Fail site alongside raise_evalerror_abort(), so the reader-layer loop-top check discards the rest of the logical line, and cleared at every pending-clearing boundary. The eval and source boundaries absorb exactly this class (GNU evalstring.c catches the expansion error locally at the top level), which is what keeps the containing boundaries unchanged.
Boundary map (pinned by probes against WSL-style GNU file-mode semantics)
Contained (line continues after the boundary): ( ) subshells, pipeline stages, $( ), & background jobs, eval, source (the discard applies inside the eval string / sourced file, the caller's line continues). A temporary assignment prefix (x=/no/such/*.zzz true) is command-level containment: the command does not run, status is 1, GNU prints no diagnostic, and the list continues.
Penetrating (rest of the logical line abandoned): brace groups, &&/|| arms, !, time, if/then bodies, if conditions, while/until/for/select bodies (the discard escapes through done and aborts the loop), case arms, function bodies (including def+call+echo on one line), nested brace groups, redirection words, compound-assignment words, for word lists, and declare with an indexed compound operand. declare -A (associative) is exempt: GNU stores the literal key and returns 0.
Tests
mod issue_753 in tests/regression.rs, per the #746 method: 9 [ratchet] cases (the issue's exact repro, list-position brace, if body / if condition / case / nested brace, for word list, time, same-line function call, redirection word, compound-assignment word, declare indexed operand) and 8 [control]/[guard] cases (containing boundaries, loop-body penetration, declare -A exemption, temp-assignment containment, set -e ordering, next-line continuation, select body with a stdin payload, source seam). Revert-gate: the 9 ratchet cases were each run against the pre-fix engine and fail there; the control/guard cases pass on both. Full suite: --lib 609 passed; --test regression 67 passed with only the two known yes|head perf-canary sandbox failures (reproduced identically on the pre-fix engine); --test cli_tests 463 passed with the two known sandbox failures (also reproduced pre-fix).
Out of scope, found while probing (both reproduce on the pre-fix engine — follow-up candidates, not regressions of this change)
c=([k]=v [""]=x) — a bad-subscript compound assignment binds partially and GNU CONTINUES the line (sub-after rc=0); rubash discards the rest of the line. Subscript family.
${arr[/no/such/*.zzz]} — the subscript failglob diagnostic reads arithmetic syntax error where GNU reads syntax error. Diagnostic wording family.
Activity
fix(executor): a failglob error abandons the rest of the logical line (…
caomengxuan666 commentedon Oct 18, 2026
Fixed in c5eb976 (
fix(executor): a failglob error abandons the rest of the logical line (#753)).Root cause
The failglob path raised
Err(ExecuteError::ExpansionFailure)and setcommand_expansion_failed, but that error was swallowed by the compound-command boundary: a brace group, if body, case arm, etc. consumed the failure and returned to the enclosing list, which then kept executing the rest of the logical line. The simple-command path already discarded the line (that is whycase3matched); only compounds leaked.Fix
A new class flag
evalerror_failglob_pendingmirrors the existingevalerror_subscript_pendingdiscipline: armed at every failglobFailsite alongsideraise_evalerror_abort(), so the reader-layer loop-top check discards the rest of the logical line, and cleared at every pending-clearing boundary. Theevalandsourceboundaries absorb exactly this class (GNU evalstring.c catches the expansion error locally at the top level), which is what keeps the containing boundaries unchanged.Boundary map (pinned by probes against WSL-style GNU file-mode semantics)
Contained (line continues after the boundary):
( )subshells, pipeline stages,$( ),&background jobs,eval,source(the discard applies inside the eval string / sourced file, the caller's line continues). A temporary assignment prefix (x=/no/such/*.zzz true) is command-level containment: the command does not run, status is 1, GNU prints no diagnostic, and the list continues.Penetrating (rest of the logical line abandoned): brace groups,
&&/||arms,!,time, if/then bodies, if conditions, while/until/for/select bodies (the discard escapes throughdoneand aborts the loop), case arms, function bodies (including def+call+echo on one line), nested brace groups, redirection words, compound-assignment words,forword lists, anddeclarewith an indexed compound operand.declare -A(associative) is exempt: GNU stores the literal key and returns 0.Tests
mod issue_753intests/regression.rs, per the #746 method: 9[ratchet]cases (the issue's exact repro, list-position brace, if body / if condition / case / nested brace,forword list,time, same-line function call, redirection word, compound-assignment word,declareindexed operand) and 8[control]/[guard]cases (containing boundaries, loop-body penetration,declare -Aexemption, temp-assignment containment,set -eordering, next-line continuation, select body with a stdin payload, source seam). Revert-gate: the 9 ratchet cases were each run against the pre-fix engine and fail there; the control/guard cases pass on both. Full suite:--lib609 passed;--test regression67 passed with only the two knownyes|headperf-canary sandbox failures (reproduced identically on the pre-fix engine);--test cli_tests463 passed with the two known sandbox failures (also reproduced pre-fix).Out of scope, found while probing (both reproduce on the pre-fix engine — follow-up candidates, not regressions of this change)
c=([k]=v [""]=x)— a bad-subscript compound assignment binds partially and GNU CONTINUES the line (sub-after rc=0); rubash discards the rest of the line. Subscript family.${arr[/no/such/*.zzz]}— the subscript failglob diagnostic readsarithmetic syntax errorwhere GNU readssyntax error. Diagnostic wording family.fix(executor): exit errors follow bash 5.3, and usage errors exit 2 (#…
fix(declare): a failglob operand failure leaves the name unmarked (#753…