Question 380
Which explanation is most relevant when A Bash script compares a numeric age using string operators and misclassifies the value 12 relative to 9?
Explanation
Correct Answer
The decisive distinction is Bash test numeric operators compare integer values rather than lexicographic strings. The targeted configuration is Use a numeric test such as [ "$age" -gt 9 ] with validated input; a proper test shows Values 8, 9 and 12 follow the intended greater-than condition.
Incorrect Answers
It is less specific than Bash test numeric operators compare integer values rather than lexicographic strings, which directly explains the scenario and supports Use a numeric test such as [ "$age" -gt 9 ] with validated input.
The related but distinct situation is “A monitoring script uses exit 0 after detecting a failed prerequisite and is treated as successful by automation”. Here, The shell communicates success and failure to callers through exit status values. For the stated problem, “Bash test numeric operators compare integer values rather than lexicographic strings” addresses the central condition.
This option serves the scenario “An operator changes PATH in one terminal but new child shells still use the old search path”. The decisive distinction is Child processes inherit exported environment variables rather than arbitrary shell variables. The present scenario is distinguished by “Bash test numeric operators compare integer values rather than lexicographic strings”.