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
[bug] Negative shift count in arithmetic is treated as a syntax error ($((8>>-1))) #1135
[bug] Negative shift count in arithmetic is treated as a syntax error ($((8>>-1)))
echo$((8>>-1));echo rc=$?# GNU bash 5.3.20: 0, rc=0 (shift count is taken modulo the word size)# rubash / niu: '8>>-1: arithmetic syntax error: operand expected', the whole expansion fails, rc=1
Expected (GNU bash 5.3.20): prints 0, exit status 0. 8<<-1 behaves the same in GNU.
Actual (rubash): arithmetic syntax error, no output, exit status 1.
Computed shift counts that can go negative (a common bit-manipulation pattern) abort expansions that GNU evaluates fine.
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
caomengxuan666 commentedon Oct 23, 2026
FIXED-BY-#1181 — verified on master (263ce53f). Commit bb3a110.
echo $((8>>-1))→0, rc=0;8<<-1same. Identical to GNU 5.3.20 (shift count wraps like C).