Bird
0
0

In bash scripting, what does the return command inside a function do?

easy🧠 Conceptual Q11 of 15
Bash Scripting - Functions
In bash scripting, what does the return command inside a function do?
AIt stops the entire script immediately.
BIt sends a numeric status code back to the caller.
CIt prints text output to the terminal.
DIt saves the function output to a file.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of return in bash functions

    The return command sends a numeric exit status (0-255) back to the caller, indicating success or failure.
  2. Step 2: Differentiate from echo

    Unlike echo, which prints text output, return only sends a number status, not text.
  3. Final Answer:

    It sends a numeric status code back to the caller. -> Option B
  4. Quick Check:

    return = numeric status [OK]
Quick Trick: Remember: return sends number status, echo prints text [OK]
Common Mistakes:
MISTAKES
  • Thinking return prints output like echo
  • Using return to output strings
  • Confusing return with exit

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes