Bird
0
0

How can you embed a here document inside a bash function that outputs a formatted message with variables expanded, ensuring no extra indentation in output?

hard🚀 Application Q9 of 15
Bash Scripting - Text Processing in Scripts
How can you embed a here document inside a bash function that outputs a formatted message with variables expanded, ensuring no extra indentation in output?
AUse <<EOF inside function with unquoted delimiter and no indentation
BUse <<-EOF inside function with unquoted delimiter and indent lines with tabs
CUse <<'EOF' inside function with quoted delimiter and indent lines with spaces
DUse <<-EOF inside function with quoted delimiter and indent lines with tabs
Step-by-Step Solution
Solution:
  1. Step 1: Understand function and here document interaction

    Inside functions, indentation is common for readability, so tabs are used to indent here document lines.
  2. Step 2: Ensure variable expansion and clean output

    Using <<-EOF with unquoted delimiter strips tabs and expands variables, producing clean output.
  3. Final Answer:

    Use <<-EOF inside function with unquoted delimiter and indent lines with tabs -> Option B
  4. Quick Check:

    Function + <<- + unquoted delimiter = clean expanded output [OK]
Quick Trick: Indent with tabs and use <<- for clean function here docs [OK]
Common Mistakes:
MISTAKES
  • Quoting delimiter disables expansion
  • Indenting with spaces not stripped
  • Not using <<- inside functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes