Bug 33820 - [ and [[ behave differently with -eq
: [ and [[ behave differently with -eq
Status: NEW
: Sisyphus
(All bugs in Sisyphus/bash)
: unstable
: all Linux
: P3 minor
Assigned To:
:
:
:
:
:
  Show dependency tree
 
Reported: 2017-08-28 18:25 by
Modified: 2017-08-28 18:25 (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2017-08-28 18:25:16
[ 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