Bug 33820

Summary: [ and [[ behave differently with -eq
Product: Sisyphus Reporter: Ivan Zakharyaschev <imz>
Component: bashAssignee: placeholder <placeholder>
Status: NEW --- QA Contact: qa-sisyphus
Severity: minor    
Priority: P3 CC: glebfm, ldv, placeholder
Version: unstable   
Hardware: all   
OS: Linux   

Description Ivan Zakharyaschev 2017-08-28 18:25:16 MSK
[ and [[ behave differently with -eq , although the info page give no hints about this:

6.4 Bash Conditional Expressions
================================

Conditional expressions are used by the '[[' compound command and the
'test' and '[' builtin commands.

...


'ARG1 OP ARG2'
     'OP' is one of '-eq', '-ne', '-lt', '-le', '-gt', or '-ge'.  These
     arithmetic binary operators return true if ARG1 is equal to, not
     equal to, less than, less than or equal to, greater than, or
     greater than or equal to ARG2, respectively.  ARG1 and ARG2 may be
     positive or negative integers.

Examples of the difference:

[imz@ovicaa ~]$ [ a -eq b ] && echo yes 
bash: [: a: integer expression expected
[imz@ovicaa ~]$ [[ a -eq b ]] && echo yes 
yes
[imz@ovicaa ~]$ rpm -q bash
bash-3.2.57-alt1


-bash-4.3# [ a -eq b ] && echo yes
-bash: [: a: integer expression expected
-bash-4.3# [[ a -eq b ]] && echo yes
yes
-bash-4.3# rpm -q bash
bash-4.3.42-alt2.x86_64