010-160 · Question #93
What is the return value of a shell script after successful execution?
The correct answer is B. 0. Unix/Linux processes return an exit code of 0 to indicate successful execution; any non-zero value signals an error or abnormal termination.
Question
Options
- A1
- B0
- C-1
- D-255
- E255
How the community answered
(24 responses)- A4% (1)
- B88% (21)
- E8% (2)
Why each option
Unix/Linux processes return an exit code of 0 to indicate successful execution; any non-zero value signals an error or abnormal termination.
Exit code 1 typically indicates a general or unspecified error, not successful execution.
By POSIX convention, a process or script that completes successfully exits with code 0. The shell and calling scripts use this value to determine if a command succeeded, making 0 the universal indicator of success in Unix-like systems.
Exit codes must be in the range 0-255; negative values like -1 are not valid POSIX exit codes.
Negative values such as -255 are outside the valid POSIX exit code range of 0 to 255.
Exit code 255 is used to indicate specific error conditions such as command not found, not successful completion.
Concept tested: Shell script exit codes and POSIX convention
Source: https://www.gnu.org/software/bash/manual/bash.html#Exit-Status
Topics
Community Discussion
No community discussion yet for this question.