Multiple choice technology programming languages

"Count the number of errors in the statement if [password = password1] then echo password else password"

  1. 0

  2. 4

  3. 1

  4. 2

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The shell script has 4 syntax errors: 1) Missing spaces inside brackets [password should be [ password, 2) Missing spaces before closing bracket password1] should be password1 ], 3) Variables should be quoted for string comparison, 4) The else clause else password is incomplete - else requires a complete command statement. Additionally, the condition itself has flawed syntax.