[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
test arithmetic operators print a incorrect error message
From: |
Emanuele Torre |
Subject: |
test arithmetic operators print a incorrect error message |
Date: |
Wed, 15 Jun 2022 20:25:43 +0200 |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin'
-DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc'
-DSYS_BASH_LOGOUT='/etc/bash.bash_logout'
-DNON_INTERACTIVE_LOGIN_SHELLS
uname output: Linux t420 5.15.46-1-lts #1 SMP Thu, 09 Jun 2022
10:12:44 +0000 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.1
Patch Level: 16
Release Status: release
Description:
test's arithmetic operatiors print an incorrect error message
when one of operands is not an integer.
It says "integer expression expected" even if it simply expects
an integer, not an expression ([['s arithmetic operators do
expect an expression, but test's don't).
Repeat-By:
bash-5.1$ [ abc -gt 2 ]
bash: [: abc: integer expression expected
bash-5.1$ [ 1 -lt 2+3 ]
bash: [: 2+3: integer expression expected
Fix:
Change the error message at line 156 of test.c[1] to
"%s: integer expected"
or
"%s: integer operand expected"
and update the translations of that message.
[1]: https://git.savannah.gnu.org/cgit/bash.git/tree/test.c?h=devel#n156
Alternatively, change the error message to:
"invalid integer %s"
and borrow translations from GNU test.
bash-5.1$ declare -p LANG
declare -x LANG="en_GB.UTF-8"
bash-5.1$ /bin/[ abc -gt 2 ]
/bin/[: invalid integer ‘abc’
bash-5.1$ LANG=C /bin/[ abc -gt 2 ]
/bin/[: invalid integer 'abc'
bash-5.1$ LANG=it_IT.utf-8 /bin/[ abc -gt 2 ]
/bin/[: intero non valido "abc"
- test arithmetic operators print a incorrect error message,
Emanuele Torre <=