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] $(( )) reads a variable with blanks around its number as 0 (n=$(wc -l < f); echo $((n+1)) prints 1) #368
Arithmetic expansion reads a variable whose value has a space before or after the number as 0, without an error. Bash accepts the blanks.
wc pads a single count read from stdin to 7 columns. GNU wc prints 2.
Counting lines with wc -l and then doing arithmetic on the result is a common idiom, and here it gives a wrong number silently. #348 makes [/test accept blanks around an integer operand, so [ "$(wc -l < f)" -eq 2 ] becomes true there; $(( )) is a separate code path.
Found while reviewing #348; it is not caused by that PR. The results are the same on main @ dbb6189 and on #348's head 9ef3e56. I ran debug builds through -c only and compared with bash 5.2.15.
Activity