Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6982511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:17:53+00:00 2026-05-27T18:17:53+00:00

Why does bash have the following behavior? echo $((true == false)) 1 I would

  • 0

Why does bash have the following behavior?

echo $((true == false))
1

I would have thought that this would print 0, but it prints 1.

This is further complicated by the following facts:

> echo $((true))
0
> echo $((false))
0
> echo $((true == true))
1
> echo $((false == false))
1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:17:54+00:00Added an answer on May 27, 2026 at 6:17 pm

    All the posters talking about 0 being true and 1 being false have missed the point. In this case, 1 is true and 0 is false in the usual boolean sense because of the arithmetic evaluation context caused by $(()).

    The == operation inside of $(()) is not equality of return statuses in Bash, it performs numeric equality using the literals given where “false” and “true” are treated as variable, but have not yet been bound, which both are interpreted as 0 since they have no value yet assigned:

    $ echo $((true))
    0
    $ echo $((false))
    0
    

    If you want to compare the return status of true and false you want something like:

    true
    TRUE=$?
    false
    FALSE=$?
    if (( $TRUE == $FALSE )); then echo TRUE; else echo FALSE; fi
    

    But, I’m not sure why you would want to do this.

    EDIT: Corrected the part in the original answer about “true” and “false” being interpreted as strings. They are not. They are treated as variables, but have no value bound to them yet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bash script that does ssh to a remote machine and executes
Does anyone know of a good Command Prompt replacement? I've tried bash/Cygwin, but that
I am working on a Bash shell script that does something like this: #!/bin/bash
On HostA, I have a process, procA , that does I/O, like so: #!/bin/bash
I have an executable that does the following: 1. outputs the string BEGIN 2.
I have a bash script in a cron job that does an SVN copy
I'm trying to write a not found handle in Bash that does the following:
Let’s say I have the following Bash script: while read SCRIPT_SOURCE_LINE; do echo $SCRIPT_SOURCE_LINE
Bash scripting does my head in. I have searched for regex assignment, but not
When I enter the following (BASH): rdesktop -r disk:bacon=~/bacon host It does not expand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.