Bird
0
0

Identify the error in this bash function definition:

medium📝 Debug Q14 of 15
Bash Scripting - Functions
Identify the error in this bash function definition:
myfunc {
  echo "Hello"
}
ANo error, function is correct
BMissing parentheses after function name
CFunction name cannot be 'myfunc'
DMissing quotes around echo argument
Step-by-Step Solution
Solution:
  1. Step 1: Check function definition syntax

    Bash functions require parentheses after the name, like myfunc().
  2. Step 2: Verify other parts

    Quotes around echo argument are correct, function name is valid, so no other errors.
  3. Final Answer:

    Missing parentheses after function name -> Option B
  4. Quick Check:

    Function syntax needs () after name [OK]
Quick Trick: Always add () after function name in bash [OK]
Common Mistakes:
MISTAKES
  • Forgetting parentheses after function name
  • Thinking quotes are required for function name
  • Assuming function names are restricted keywords

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes