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:
Step 1: Review bash function behavior
Bash functions share the same variable scope as the main script unless variables are explicitly declared local.
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.
Final Answer:
Functions share the same variable scope as the main script by default -> Option B
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
Master "Functions" in Bash Scripting
9 interactive learning modes - each teaches the same concept differently