po: Update German man pages translation
[dpkg.git] / src / sh / dpkg-error.sh
blobb7f968e030a239baff6a69ad0a04fc563fddb256
2 # Copyright © 2010 Raphaël Hertzog <hertzog@debian.org>
3 # Copyright © 2011-2015 Guillem Jover <guillem@debian.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
18 # shellcheck shell=sh
20 # Standard ANSI colors and attributes.
21 COLOR_NORMAL=''
22 COLOR_RESET='\e[0m'
23 COLOR_BOLD='\e[1m'
24 COLOR_BLACK='\e[30m'
25 COLOR_RED='\e[31m'
26 COLOR_GREEN='\e[32m'
27 COLOR_YELLOW='\e[33m'
28 COLOR_BLUE='\e[34m'
29 COLOR_MAGENTA='\e[35m'
30 COLOR_CYAN='\e[36m'
31 COLOR_WHITE='\e[37m'
32 COLOR_BOLD_BLACK='\e[1;30m'
33 COLOR_BOLD_RED='\e[1;31m'
34 COLOR_BOLD_GREEN='\e[1;32m'
35 COLOR_BOLD_YELLOW='\e[1;33m'
36 COLOR_BOLD_BLUE='\e[1;34m'
37 COLOR_BOLD_MAGENTA='\e[1;35m'
38 COLOR_BOLD_CYAN='\e[1;36m'
39 COLOR_BOLD_WHITE='\e[1;37m'
41 setup_colors()
43 : "${DPKG_COLORS=auto}"
45 case "$DPKG_COLORS" in
46 auto)
47 if [ -t 1 ]; then
48 USE_COLORS=yes
49 else
50 USE_COLORS=no
53 always)
54 USE_COLORS=yes
57 USE_COLORS=no
59 esac
61 if [ $USE_COLORS = yes ]; then
62 COLOR_PROG="$COLOR_BOLD"
63 COLOR_INFO="$COLOR_GREEN"
64 COLOR_NOTICE="$COLOR_YELLOW"
65 COLOR_WARN="$COLOR_BOLD_YELLOW"
66 COLOR_ERROR="$COLOR_BOLD_RED"
67 else
68 COLOR_RESET=""
70 FMT_PROG="$COLOR_PROG$PROGNAME$COLOR_RESET"
73 debug() {
74 if [ -n "$DPKG_DEBUG" ]; then
75 echo "DEBUG: $FMT_PROG: $*" >&2
79 error() {
80 echo "$FMT_PROG: ${COLOR_ERROR}error${COLOR_RESET}: $*" >&2
81 exit 1
84 warning() {
85 echo "$FMT_PROG: ${COLOR_WARN}warning${COLOR_RESET}: $*" >&2
88 badusage() {
89 echo "$FMT_PROG: ${COLOR_ERROR}error${COLOR_RESET}: $1" >&2
90 echo >&2
91 echo "Use '$PROGNAME --help' for program usage information." >&2
92 exit 1