[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Regression in 5.2 in arithmetic comparison
From: |
Glenn Jackman |
Subject: |
Regression in 5.2 in arithmetic comparison |
Date: |
Tue, 18 Oct 2022 15:55:50 -0400 |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2
uname output: Linux exercism-vm 5.15.0-50-generic #56-Ubuntu SMP Tue Sep 20
13:23:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.2
Patch Level: 0
Release Status: release
Description:
an arithmetic comparison where an array index contains an array
element fails.
Repeat-By:
in bash 5.2
$ coins[3]=10 i=3 C[5]=42 p=15
$ # comparison throws error
$ (( C[p - coins[i]] > 10)) && echo Y || echo N
bash: p - coins\[i\]: syntax error: invalid arithmetic
operator (error token is "\[i\]")
$ # but arithmetic expression is OK
$ echo $(( C[p - coins[i]] ))
42
compare to bash 5.1
$ coins[3]=10 i=3 C[5]=42 p=15
$ (( C[p - coins[i]] > 10)) && echo Y || echo N
Y
$ echo $(( C[p - coins[i]] ))
42
- Regression in 5.2 in arithmetic comparison,
Glenn Jackman <=