nerdexam
CompTIA

LX0-104 · Question #459

You are writing a script and want to test the exit status of a process. Which of the following is true?

The correct answer is D. The normal exit value is 0.. In shell scripting, processes typically return an exit status, which is a numerical value indicating the success or failure of the command or script.

Shells, Scripting and Data Management

Question

You are writing a script and want to test the exit status of a process. Which of the following is true?

Options

  • AThe normal exit value differs.
  • BYou can't test the normal exit value.
  • CThe normal exit value is $EXIT.
  • DThe normal exit value is 0.

How the community answered

(42 responses)
  • A
    5% (2)
  • B
    2% (1)
  • D
    93% (39)

Why each option

In shell scripting, processes typically return an exit status, which is a numerical value indicating the success or failure of the command or script.

AThe normal exit value differs.

The normal exit value for success is consistently 0 across Unix-like systems, not differing.

BYou can't test the normal exit value.

The exit value can always be tested in shell scripts using special variables like `$?`.

CThe normal exit value is $EXIT.

`$EXIT` is not a standard shell variable for the exit status; the correct variable is `$?`.

DThe normal exit value is 0.Correct

By convention, an exit status of 0 signifies successful execution of a command or script, while any non-zero value indicates an error or abnormal termination. This convention allows scripts to test the outcome of operations reliably.

Concept tested: Shell script exit status convention

Source: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Exit-Status

Topics

#exit status#shell scripting#process management#return codes

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice