Correct answersA. A function must be defined earlier in the script than the line that calls it.B. A variable declared with local is limited to the function and the functions it calls.D. A variable assigned in a function without local remains set in the calling shell afterward.
AWhy this is right: Bash runs a script line by line, so a call fails if the function has not been defined yet.
BWhy this is right: Bash scoping is dynamic, so a local variable is visible to the function and the functions it calls.
CWhy not this: return ends only the function and sets its exit status; exit is what ends the script.
DWhy this is right: Variables in Bash are global by default, so an assignment without local stays set after the call.
EWhy not this: $0 keeps the script name inside a function; the function name is in the FUNCNAME array.
FWhy not this: return accepts only an integer status from 0 to 255; strings are passed back by echo and command substitution.
Bash reads a script sequentially, so definitions must precede calls. Variables are global unless declared local, and local ones are scoped to the function and its callees. The return builtin only ends the function, not the script; exit ends the script. Inside a function $0 is still the script name (FUNCNAME holds the function name), and return takes only a number from 0 to 255.