Question 360
A shell script detects invalid input and must return a failure status to the caller. One student proposes Use exit 1 after the validation error and another proposes Open the file with nano script.sh. Which technical comparison is the soundest?
Explanation
Correct Answer
Correct distinction: Use exit 1 after the validation error targets report failure exit status; A nonzero exit status signals an error to callers and automation. The compared alternative instead serves basic text editing in nano.
Incorrect Answers
Incorrect mapping: Open the file with nano script.sh is used for basic text editing in nano. It does not displace Use exit 1 after the validation error for the described requirement.
The mechanisms are different: A nonzero exit status signals an error to callers and automation. By contrast, nano provides a terminal-based text editor with visible command hints. They are not universally interchangeable.
The third option addresses modal editing in vi: vi is modal; i enters insert mode so text can be typed. The original action remains relevant because A nonzero exit status signals an error to callers and automation.