Skip to content

expr: fix eager evaluation of parenthesized dead branches#11395

Open
can1357 wants to merge 1 commit intouutils:mainfrom
can1357:expr-fix-eager-evaluation-of-parenthesized-dead-branches
Open

expr: fix eager evaluation of parenthesized dead branches#11395
can1357 wants to merge 1 commit intouutils:mainfrom
can1357:expr-fix-eager-evaluation-of-parenthesized-dead-branches

Conversation

@can1357
Copy link

@can1357 can1357 commented Mar 18, 2026

uutils expr evaluates parenthesized subexpressions during parsing, so arithmetic errors in dead | and & branches are raised before short-circuiting. GNU parses those branches without forcing evaluation and only evaluates when the branch is actually needed.

Reproduction Steps

expr 1 '|' '(' 1 / 0 ')'
# Expected (GNU): exit 0, stdout "1", no stderr
# Actual (uutils): exit 2, stderr "expr: division by zero"

Impact

Guarded expressions can fail with hard errors instead of boolean results, which breaks GNU-compatible shell control flow and error handling.

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