The script uses 'else if' for conditional branching, which is not the correct syntax in shell scripting. Use 'elif' instead of 'else if' to properly structure conditional statements in shell scripts.
1
2# Noncompliant: Uses `else if` which is not valid shell syntax for alternative conditions.
3if [ "$fruit" = "apple" ]
4then
5 echo "It's an apple"
6else if [ "$fruit" = "banana" ]
7then
8 echo "It's a banana"
9else
10 echo "It's something else"
11fi fi1
2# Compliant: Uses `elif` for proper alternative condition checking in shell scripts.
3if [ "$fruit" = "apple" ]
4then
5 echo "It's an apple"
6elif [ "$fruit" = "banana" ]
7then
8 echo "It's a banana"
9else
10 echo "It's something else"
11fi