Bird
0
0

Why does this function cause an error?

medium📝 Debug Q7 of 15
Bash Scripting - Functions
Why does this function cause an error?
hello() 
  echo "Hello"
}
AEcho command is invalid
BMissing parentheses after function name
CMissing opening brace '{' after function name
DExtra closing brace '}'
Step-by-Step Solution
Solution:
  1. Step 1: Check function syntax

    Functions must have an opening brace '{' immediately after the parentheses to start the body.
  2. Step 2: Analyze the code

    The function 'hello()' is missing the opening brace '{', causing a syntax error.
  3. Final Answer:

    Missing opening brace '{' after function name -> Option C
  4. Quick Check:

    Function body must start with '{' after parentheses [OK]
Quick Trick: Always add '{' after function parentheses [OK]
Common Mistakes:
MISTAKES
  • Forgetting opening brace
  • Misplacing closing brace
  • Incorrect function body indentation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes