Bird
0
0

What happens if you try to unset a variable marked as readonly in bash?

easy🧠 Conceptual Q1 of 15
Bash Scripting - Variables
What happens if you try to unset a variable marked as readonly in bash?
AThe variable is unset without any error
BThe variable value changes to empty string
CThe variable cannot be unset and an error is shown
DThe script exits immediately
Step-by-Step Solution
Solution:
  1. Step 1: Understand the behavior of readonly variables

    Readonly variables cannot be changed or unset once set.
  2. Step 2: Effect of unset on readonly variable

    Trying to unset a readonly variable causes an error and the variable remains set.
  3. Final Answer:

    The variable cannot be unset and an error is shown -> Option C
  4. Quick Check:

    Readonly variable unset = error [OK]
Quick Trick: Readonly variables cannot be unset or changed [OK]
Common Mistakes:
MISTAKES
  • Assuming unset works on readonly variables
  • Thinking readonly variables become empty on unset
  • Believing script exits on unset attempt

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes