Skip to content

[bug] (( )) arithmetic error diagnostic ignores the command's own 2>&1 redirection #1127

Closed

Description

@caomengxuan666

[bug] (( )) arithmetic error diagnostic ignores the command's own 2>&1 redirection

a=1x; ((a+=1)) 2>&1; echo "a=$a rc=$?"
# GNU bash 5.3.20: stdout contains the diagnostic '((: 1x: value too great for base ...' followed by 'a=1x rc=1'; stderr is empty
# rubash / niu:     stdout is only 'a=1x rc=1'; the diagnostic leaks to the shell's stderr instead

Expected (GNU bash 5.3.20): the diagnostic honours the 2>&1 attached to the (( )) command and lands on stdout.
Actual (rubash): the diagnostic is written to the shell's outer stderr, ignoring the redirection.

Wrappers that capture a command's combined output (out=$(cmd 2>&1), log redirection) lose arithmetic diagnostics entirely.

Env: rubash master 493ebb2 / niubash 1.4.4 (niu, master 953f513, embeds rubash 493ebb2), Linux x86_64, GNU bash 5.3.20 x86_64-pc-linux-gnu as oracle. Also reproduces in niu (same engine).

Activity

  1. caomengxuan666 commented on Oct 23, 2026

    @caomengxuan666
    MemberAuthor

    FIXED-BY-#1181 — verified on master (263ce53f). Commit c2d1784.

    a=1x; ((a+=1)) 2>&1; echo "a=$a rc=$?" → diagnostic lands on stdout followed by a=1x rc=1, identical to GNU 5.3.20.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions