Bird
0
0

Which statement about bash function definitions is TRUE?

hard🧠 Conceptual Q10 of 15
Bash Scripting - Functions
Which statement about bash function definitions is TRUE?
AFunctions do not need to be declared before they are called in the script
BFunctions share the same variable scope as the main script by default
CFunction definitions cannot be nested inside other functions
DFunction names can contain spaces if quoted
Step-by-Step Solution
Solution:
  1. Step 1: Review bash function behavior

    Bash functions share the same variable scope as the main script unless variables are explicitly declared local.
  2. Step 2: Evaluate each statement

    A is false because functions must be declared before they are called in the script. C is false because bash does support nested function definitions. D is false because function names cannot contain spaces even if quoted.
  3. Final Answer:

    Functions share the same variable scope as the main script by default -> Option B
  4. Quick Check:

    Bash functions share script scope unless variables are local [OK]
Quick Trick: Bash functions share script variables unless declared local [OK]
Common Mistakes:
MISTAKES
  • Thinking functions do not need to be declared first
  • Using spaces in function names
  • Expecting nested function support

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes