Bird
0
0

Identify the error in this script:

medium📝 Debug Q6 of 15
Bash Scripting - Variables
Identify the error in this script:
readonly MYVAR
MYVAR=100
AMYVAR is made readonly before assignment
BMissing value assignment before readonly
CSyntax error in readonly command
DNo error, script runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check how MYVAR is declared readonly

    MYVAR is marked readonly without a value assigned first.
  2. Step 2: Assign value after readonly

    Assigning value after readonly causes error because variable is locked but empty.
  3. Final Answer:

    MYVAR is made readonly before assignment -> Option A
  4. Quick Check:

    Assign value before readonly to avoid error [OK]
Quick Trick: Assign value before readonly to avoid errors [OK]
Common Mistakes:
MISTAKES
  • Marking variable readonly before assigning value
  • Assuming readonly assigns default value
  • Ignoring error messages

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes