3
########################
5
# sysexits.bash - Exit status codes for system programs.
7
# Copyright 2013 Bruno Félix Rezende Ribeiro (oitofelix)
8
# <oitofelix@gmail.com>
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation, either version 3 of the License, or
13
# (at your option) any later version.
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU General Public License for more details.
20
# You should have received a copy of the GNU General Public License
21
# along with this program. If not, see <http://www.gnu.org/licenses/>.
23
########################
25
########################
27
# Copyright (c) 1987, 1993
28
# The Regents of the University of California. All rights reserved.
30
# Redistribution and use in source and binary forms, with or without
31
# modification, are permitted provided that the following conditions
33
# 1. Redistributions of source code must retain the above copyright
34
# notice, this list of conditions and the following disclaimer.
35
# 2. Redistributions in binary form must reproduce the above copyright
36
# notice, this list of conditions and the following disclaimer in the
37
# documentation and/or other materials provided with the distribution.
38
# 4. Neither the name of the University nor the names of its contributors
39
# may be used to endorse or promote products derived from this software
40
# without specific prior written permission.
42
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
43
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
46
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54
########################
56
# If this library is already loaded exit with success. If not, mark
57
# it to not load again and continue the loading process.
58
[ -v _SYSEXITS_BASH ] && return $EX_OK
59
declare -ri _SYSEXITS_BASH=1
61
# Inform the system what library is being loaded.
62
declare PROGRAM=sysexits.bash
64
# This library define constants to use with the bash exit built in as
67
# Error numbers begin at EX__BASE to reduce the possibility of
68
# clashing with other exit statuses that random programs may already
69
# return. The meaning of the codes is approximately as follows:
71
# EX_USAGE -- The command was used incorrectly, e.g., with the wrong
72
# number of arguments, a bad flag, a bad syntax in a
73
# parameter, or whatever.
75
# EX_DATAERR -- The input data was incorrect in some way. This
76
# should only be used for user's data & not system
79
# EX_NOINPUT -- An input file (not a system file) did not exist or
80
# was not readable. This could also include errors
81
# like "No message" to a mailer (if it cared to catch
84
# EX_NOUSER -- The user specified did not exist. This might be used
85
# for mail addresses or remote logins.
87
# EX_NOHOST -- The host specified did not exist. This is used in
88
# mail addresses or network requests.
90
# EX_UNAVAILABLE -- A service is unavailable. This can occur if a
91
# support program or file does not exist. This can
92
# also be used as a catchall message when something
93
# you wanted to do doesn't work, but you don't know
96
# EX_SOFTWARE -- An internal software error has been detected. This
97
# should be limited to non-operating system related
100
# EX_OSERR -- An operating system error has been detected. This is
101
# intended to be used for such things as "cannot fork",
102
# "cannot create pipe", or the like. It includes things
103
# like getuid returning a user that does not exist in the
106
# EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp, etc.)
107
# does not exist, cannot be opened, or has some sort of
108
# error (e.g., syntax error).
110
# EX_CANTCREAT -- A (user specified) output file cannot be created.
112
# EX_IOERR -- An error occurred while doing I/O on some file.
114
# EX_TEMPFAIL -- temporary failure, indicating something that
115
# is not really an error. In sendmail, this means
116
# that a mailer (e.g.) could not create a connection,
117
# and the request should be reattempted later.
119
# EX_PROTOCOL -- the remote system returned something that
120
# was "not possible" during a protocol exchange.
122
# EX_NOPERM -- You did not have sufficient permission to
123
# perform the operation. This is not intended for
124
# file system problems, which should use NOINPUT or
125
# CANTCREAT, but rather for higher level permissions.
128
declare -ri EX_OK=0 # successful termination
130
declare -ri EX__BASE=64 # base value for error messages
132
declare -ri EX_USAGE=64 # command line usage error
133
declare -ri EX_DATAERR=65 # data format error
134
declare -ri EX_NOINPUT=66 # cannot open input
135
declare -ri EX_NOUSER=67 # addressee unknown
136
declare -ri EX_NOHOST=68 # host name unknown
137
declare -ri EX_UNAVAILABLE=69 # service unavailable
138
declare -ri EX_SOFTWARE=70 # internal software error
139
declare -ri EX_OSERR=71 # system error (e.g., can't fork)
140
declare -ri EX_OSFILE=72 # critical OS file missing
141
declare -ri EX_CANTCREAT=73 # can't create (user) output file
142
declare -ri EX_IOERR=74 # input/output error
143
declare -ri EX_TEMPFAIL=75 # temp failure; user is invited to retry
144
declare -ri EX_PROTOCOL=76 # remote error in protocol
145
declare -ri EX_NOPERM=77 # permission denied
146
declare -ri EX_CONFIG=78 # configuration error
148
declare -ri EX__MAX=78 # maximum listed value
150
# Inform that the library was successfully loaded.