Conditional Logic Lab - Q1

Hello,

Let me know If I am wrong here !

I found there should be double brackets in the if section ex: [[ $rocket_status = “failed” ]]

In the Solution section as shared it is only single brackets like [ $rocket_status = “failed” ]

When I used with single brackets it did not worked in the Lab. When I used double brackets it worked.

Kindly check and Let me know

Hi @rakshitsiddalingappa

I tried with a single bracket and it did work at my end. As we are not evaluating any complex expression, so using [] command/syntax will work. If the expressions are complex, using the [[]] keyword/syntax could be helpful.

You can read more about this here and Bookmark this bash manual for reference.

1 Like

Hi @Santosh_KodeKloud ,

I tried copying the solution into the file and it did not worked with the single [].

With the same solution, When I used double [[]]. It worked.

I hope we are in the same page here.

I tried using the one in the Solution with [] and it passed.

Okay then there might be a caching issue. Trying the same solution by refreshing the site or the lab may works.

Hi,

Yes, I noticed that too. The double brackets ([[ ]]) are a Bash-specific feature that offer more flexibility and safer comparisons compared to the older single brackets ([ ]).

In modern scripts, using [[ ]] is generally recommended, so it’s perfectly fine to use them if they’re working better in your lab.

Hope this helps!