To set the exit status of a shell script 1

To set the exit status of a shell script

#!/bin/sh
if cp "$1" "$1.bak"
then
    vi "$1"
    exit   # USE STATUS FROM vi
else
    echo "bkedit quitting: can't make backup?" 1>&2
    exit 1
fi

Here is what the above code is Doing:
1. It makes a backup copy of the file to be edited.
2. It runs the vi editor on the file.
3. It exits with the same status as vi.

The exit status of a command is a number between 0 and 255.
A status of 0 means that the command succeeded.
A nonzero status means that the command failed.

The exit status of the last command executed is stored in the shell variable $?.

The exit command is used to exit a shell script, just as in a C program.
If n is omitted, the exit status is that of the last command executed.

The exit status is an integer number.
If n is omitted, the exit status is that of the last command executed.
A successful command returns a status of zero.
An unsuccessful command returns a status of 1-255.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be used to terminate a script before reaching the end.

The exit command may also be

Similar Posts