Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16299
| Path | csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Inian Vasanth <inian.vasanth@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | behavior of arithmetic evaluation operator inside extended test operator |
| Date | Tue, 19 May 2020 18:10:30 +0530 |
| Lines | 57 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.561.1589896302.3227.bug-bash@gnu.org> (permalink) |
| References | <CADNZbLQ8p9ggi3pzwY1LKk=O2T4_a9W2Awap3bXSzGQxhNN=uQ@mail.gmail.com> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| X-Trace | usenet.stanford.edu 1589896302 12526 209.51.188.17 (19 May 2020 13:51:42 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=NvsCs251wH8NPOvRZSCZSJuiHBRZqWXK5ZLMi8TwJfo=; b=GGuidI/xqPZ1/NGEkk6LDoQd9NKMaqYwSMmuxo1FQ87lkvG2zcG+y3VKSzQVuSd7ak v/yusXgreEO6UAq7XRhy1vCqMwBrezvqng5dukPAROb60ily3qnb/eaKmVyvgtlSCbPD OkHAite8Fa9vnuucdMM9BlMiKAP/LAZbVlCdkJf50RjwhGljabBJkMYYwlDqTG3mtlIT unvoBvE61Vz3gekLUhtZFnuA6yWSeDZGwxhRRmRuxGDWicQPggUmRgz/d2bYLfdYxnjy 5Vf5uBogaiTAdiVL2vgJq63kvgCQ2VeUHY6sBRT+YTAbRYei04O2WXY0gZlNJ8efc8I/ Xozg== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=NvsCs251wH8NPOvRZSCZSJuiHBRZqWXK5ZLMi8TwJfo=; b=GI84pnKmeCxnzW+HEEeNskiRF0qzbQI1y+S6kYfQH1dAVpYwh3U3L4HPDIm8wa8LSQ 74PbXXwMujTaZKGErIB4nUAypi909dxcPagqky0IqMvh/QFDLGSkQ7plIbszrKJgfzb0 21fExtMHJQIXqeuGCwl0NT6eWlPL+5PxcXXrbvFrhVkxvs+MkPOoQta9rbELBDyzZGjw IT5fzr8KKYOtH7i3rizM9HWxWbm8De24pdQD1xiLf8ZIioj4Y00umjs3iToyrlZ0nUSV Fme020CDlnng9JlaQAwVDRH6Ur5hqMJwRQH6HfeTHIK1vy11xptv4nyPXqvz26ajfoKI Ny9A== |
| X-Gm-Message-State | AOAM530OutonMkEOfzlIqTBDbEHi6Z5xTJIjL83IAV359NFH/pYypDSC sWqTlyaJgjEG1nXE1gJJ0c/ykilF73GHVlrRwUg1UlC5B5Q= |
| X-Google-Smtp-Source | ABdhPJzgFgK5KaNstTD/zR4klPWkV07/A0G7Tihl3VcwnAh/FTtGcSQrxlekeHIAwjmM3iYmw5PAzVeJayhy4IThU48= |
| X-Received | by 2002:ab0:594b:: with SMTP id o11mr15436900uad.98.1589892041152; Tue, 19 May 2020 05:40:41 -0700 (PDT) |
| Received-SPF | pass client-ip=2607:f8b0:4864:20::929; envelope-from=inian.vasanth@gmail.com; helo=mail-ua1-x929.google.com |
| X-detected-operating-system | by eggs.gnu.org: No matching host in p0f cache. That's all we know. |
| X-Spam_score_int | -20 |
| X-Spam_score | -2.1 |
| X-Spam_bar | -- |
| X-Spam_report | (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN |
| X-Spam_action | no action |
| X-Mailman-Approved-At | Tue, 19 May 2020 09:51:40 -0400 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.23 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.23 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <https://lists.gnu.org/archive/html/bug-bash> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CADNZbLQ8p9ggi3pzwY1LKk=O2T4_a9W2Awap3bXSzGQxhNN=uQ@mail.gmail.com> |
| Xref | csiph.com gnu.bash.bug:16299 |
Show key headers only | View raw
Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -g -O2 -Wno-parentheses -Wno-format-security uname output: Linux DevVM 3.10.0-123.20.1.el7.x86_64 #1 SMP Thu Jan 29 18:05:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-unknown-linux-gnu Bash Version: 4.4 Patch Level: 0 Release Status: release Description: The behavior of arithmetic context operator $((..)) inside [[..]] is not so well defined. The GNU bash documentation says that $((..)) is not one of the valid primaries supported inside [[..]]. The downside is the operator without $ when used as ((..)) just behaves as double grouping, but $((..)) behaves as a valid arithmetic evaluation followed by non empty string comparison `-n` Steps The first snippet produces incorrect results because of lexicographic comparison of the two operands, while the second does an actual arithmetic evaluation which is NOT DOCUMENTED but in the end does a string not empty check with (-n 0) of the arithmetic evaluation result (not the exit code). This behavior needs to be explained clearly or documented well. bash -cx '[[ (( 100 < 3 )) ]] && echo ok' + bash -cx '[[ (( 100 < 3 )) ]] && echo ok' + [[ 100 < 3 ]] + echo ok bash -cx '[[ $(( 100 < 3 )) ]] && echo ok' + bash -cx '[[ $(( 100 < 3 )) ]] && echo ok' + [[ -n 0 ]] + echo ok ok bash -cx '[[ $(( 100 < 300 )) ]] && echo ok' + bash -cx '[[ $(( 100 < 300 )) ]] && echo ok' + [[ -n 1 ]] + echo ok ok -- Regards, INIAN VASANTH P
Back to gnu.bash.bug | Previous | Next | Find similar
behavior of arithmetic evaluation operator inside extended test operator Inian Vasanth <inian.vasanth@gmail.com> - 2020-05-19 18:10 +0530
csiph-web