Bird
0
0

You want a bash function to output a message and also return a status code. Which is the correct way to do this?

hard🚀 Application Q8 of 15
Bash Scripting - Functions
You want a bash function to output a message and also return a status code. Which is the correct way to do this?
AUse <code>return</code> for message, then <code>echo</code> for status code
BUse <code>echo</code> for message, then <code>return</code> for status code
CUse only <code>echo</code> for both message and status
DUse only <code>return</code> for both message and status
Step-by-Step Solution
Solution:
  1. Step 1: Understand echo and return roles

    echo prints messages; return sends status codes.
  2. Step 2: Combine both correctly

    First print message with echo, then send status with return.
  3. Final Answer:

    Use echo for message, then return for status code -> Option B
  4. Quick Check:

    Message with echo, status with return = A [OK]
Quick Trick: Echo message first, then return status [OK]
Common Mistakes:
MISTAKES
  • Swapping echo and return roles
  • Using return to print messages
  • Ignoring return status

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes