Bird
0
0

What is wrong with this function call?

medium📝 Debug Q7 of 15
Bash Scripting - Functions
What is wrong with this function call?
print_msg() {
  echo "$1"
}
print_msg
ASyntax error in function definition
BNo argument was passed, so output will be empty
CMissing parentheses in function call
DFunction name is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Check function call and parameters

    The function expects one argument accessed as $1, but none was given.
  2. Step 2: Understand output behavior

    Without argument, echo prints an empty line, no error occurs.
  3. Final Answer:

    No argument was passed, so output will be empty -> Option B
  4. Quick Check:

    Missing argument leads to empty output = D [OK]
Quick Trick: Always pass arguments if function uses $1, $2, etc. [OK]
Common Mistakes:
MISTAKES
  • Expecting syntax error without one
  • Thinking parentheses needed in call
  • Assuming function name is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes