Skip to content

Commit 25b217f

Browse files
committed
Misc: Move shared functions out of make-release.sh
- Move shared functions in make-release.sh to a separate file, functions.sh . - Add more comments to make-release.sh and functions.sh .
1 parent e4ff1a5 commit 25b217f

File tree

2 files changed

+54
-33
lines changed

2 files changed

+54
-33
lines changed

functions.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
# Shared functions for various supporting scripts of compton
4+
# Mostly copied from Gentoo gentoo-functions
5+
6+
GOOD=$'\e[32;01m'
7+
WARN=$'\e[33;01m'
8+
BAD=$'\e[31;01m'
9+
HILITE=$'\e[36;01m'
10+
BRACKET=$'\e[34;01m'
11+
NORMAL=$'\e[0m'
12+
13+
# @FUNCTION: eerror
14+
# @USAGE: [message]
15+
# @DESCRIPTION:
16+
# Show an error message.
17+
eerror() {
18+
echo -e "$@" | while read -r ; do
19+
echo " $BAD*$NORMAL $REPLY" >&2
20+
done
21+
return 0
22+
}
23+
24+
# @FUNCTION: einfo
25+
# @USAGE: [message]
26+
# @DESCRIPTION:
27+
# Show a message.
28+
einfo() {
29+
echo -e "$@" | while read -r ; do
30+
echo " $GOOD*$NORMAL $REPLY"
31+
done
32+
return 0
33+
}
34+
35+
# @FUNCTION: die
36+
# @USAGE:
37+
# @DESCRIPTION:
38+
# Print the call stack and the working directory, then quit the shell.
39+
die() {
40+
eerror "Call stack:"
41+
(( n = ${#FUNCNAME[@]} - 1 ))
42+
while (( n > 0 )); do
43+
funcname=${FUNCNAME[$((n - 1))]}
44+
sourcefile=$(basename ${BASH_SOURCE[${n}]})
45+
lineno=${BASH_LINENO[$((n - 1))]}
46+
eerror " ${sourcefile}:${lineno} - Called ${funcname}()"
47+
(( n-- ))
48+
done
49+
eerror "Working directory: '$(pwd)'"
50+
exit 1
51+
}

make-release.sh

+3-33
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,9 @@
11
#!/bin/bash
22

3-
GOOD=$'\e[32;01m'
4-
WARN=$'\e[33;01m'
5-
BAD=$'\e[31;01m'
6-
HILITE=$'\e[36;01m'
7-
BRACKET=$'\e[34;01m'
8-
NORMAL=$'\e[0m'
3+
# Make a release source tarball containing pre-built documentation
94

10-
eerror() {
11-
echo -e "$@" | while read -r ; do
12-
echo " $BAD*$NORMAL $RC_INDENTATION$REPLY" >&2
13-
done
14-
return 0
15-
}
16-
17-
einfo() {
18-
echo -e "$@" | while read -r ; do
19-
echo " $GOOD*$NORMAL $REPLY"
20-
done
21-
return 0
22-
}
23-
24-
die() {
25-
eerror "Call stack:"
26-
(( n = ${#FUNCNAME[@]} - 1 ))
27-
while (( n > 0 )); do
28-
funcname=${FUNCNAME[$((n - 1))]}
29-
sourcefile=$(basename ${BASH_SOURCE[${n}]})
30-
lineno=${BASH_LINENO[$((n - 1))]}
31-
eerror " ${sourcefile}:${lineno} - Called ${funcname}()"
32-
(( n-- ))
33-
done
34-
eerror "Working directory: '$(pwd)'"
35-
exit 1
36-
}
5+
BASE_DIR=$(dirname "$0")
6+
. "${BASE_DIR}/functions.sh"
377

388
main() {
399
TMP=/tmp

0 commit comments

Comments
 (0)