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 9010823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:33:54+00:00 2026-06-16T02:33:54+00:00

Consider, below code works as expected: if [[ $SOME_VARIABLE = TRUE ]]; then echo

  • 0

Consider, below code works as expected:

if [[ $SOME_VARIABLE = "TRUE" ]]; then
   echo "Only echoed when \$SOME_VARIABLE stores string \"TRUE\"."
fi

But when I remove the space surrounding the equality operator it always evaluates to 0 exit status (At least that’s what I assume it must be returning as it is taken as true):

if [[ $SOME_VARIABLE="TRUE" ]]; then
   echo "Always true."
fi

UPDATE:

Just to confirm whether the issue lies with the equality operator or not:

#!usr/bin/ksh

SOME_VARIABLE=FALSE

if [[ $SOME_VARIABLE == "TRUE" ]]; then
   echo "Only echoed when \$SOME_VARIABLE stores string \"TRUE\"."
fi


if [[ $SOME_VARIABLE=="TRUE" ]]; then
   echo "Always true."
fi


[kent@TEST]$ sh test.sh
Always true.

UPDATE:

Summary:

  1. Using = is the same as == above, but is obsolete.
  2. ALWAYS mind your spaces.
  • 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-06-16T02:33:55+00:00Added an answer on June 16, 2026 at 2:33 am

    From ksh(1):

    Conditional Expressions.

       A conditional expression is used with the [[ compound command  to  test
       attributes  of  files and to compare strings.  Field splitting and file
       name generation are not performed on the words between [[ and ]].  Each
       expression  can  be constructed from one or more of the following unary
       or binary expressions:
    
       **string** True, if string is not null.
    
       ...
    

    So the following expression is true:

    [[ somestring ]]
    

    Now consider your second example:

    if [[ $SOME_VARIABLE="TRUE" ]]; then
    

    Assuming $SOME_VARIABLE is “SOMETHINGNOTTRUE”, this expands to:

    if [[ SOMETHINGNOTTRUE=TRUE ]]; then
    

    “SOMETHINGNOTTRUE=TRUE” is a non-zero length string. It is therefore true.

    If you want to use operators inside of [[, you must put spaces around them as given in the docs (note the spaces):

       string == pattern
              True, if string matches pattern.  Any part  of  pattern  can  be
              quoted to cause it to be matched as a string.  With a successful
              match to a pattern, the .sh.match array  variable  will  contain
              the match and sub-pattern matches.
       string = pattern
              Same as == above, but is obsolete.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the code below, private void Convert_Click(Object sender, RoutedEventArgs e) { string[] strCmdLineParams =
I have a code snippet as below <CheckBox Name=cb Margin=1,2,1,0 IsChecked={Binding Path=IsManager} IsEnabled=True/> Consider
Please, consider the code below: template<typename T> bool function1(T some_var) { return true; }
Consider the code below. I don't understand why my GCC compiler does not try
Consider the JavaScript code below, inspired from the YUI documentation on YAHOO.lang.extend . In
Consider the Java code below, what would happen if there were no paintComponent method
I am having trouble finding an answer to this. Consider the clipping code below:
Consider the below String String names = Bharath-Vinayak-Harish-Punith I want to get output in
consider below code class Repository{ public static Item i; //Item is a type (class)
Consider the below piece of code: searchList=[hello, hello world, world] pattern = 'hell' matchingList

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.