nerdexam
LPI

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.

The Power of the Command Line

Question

What is the return value of a shell script after successful execution?

Options

  • A1
  • B0
  • C-1
  • D-255
  • E255

How the community answered

(24 responses)
  • A
    4% (1)
  • B
    88% (21)
  • E
    8% (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.

A1

Exit code 1 typically indicates a general or unspecified error, not successful execution.

B0Correct

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.

C-1

Exit codes must be in the range 0-255; negative values like -1 are not valid POSIX exit codes.

D-255

Negative values such as -255 are outside the valid POSIX exit code range of 0 to 255.

E255

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

#exit code#shell scripting#return value#bash

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice