summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-12-02 14:14:04 +0200
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-12-03 15:27:55 +0200
commitcef23c5cc440fc9c4620eb6cbe3263aa3b7cd030 (patch)
tree0835f26261bc4adc1a81edfc743151384f2fc848
parent0655583a969b883856124908987564015570ac0f (diff)
downloadaiaiai-cef23c5cc440fc9c4620eb6cbe3263aa3b7cd030.tar.gz
Use a helper for the 'fatal()' function
Unfortunately libshell's "fatal()" does not prefix messages with an "Error" prefix. Introduce a new helper called "die()" which prepends messages with "Fatal error". Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
-rwxr-xr-xaiaiai-diff-log2
-rwxr-xr-xaiaiai-make-kernel2
-rwxr-xr-xaiaiai-match-keywords2
-rw-r--r--aiaiai-sh-functions13
-rwxr-xr-xaiaiai-test-bisectability2
-rwxr-xr-xaiaiai-test-patchset12
-rwxr-xr-xemail/aiaiai-email-dispatcher2
-rwxr-xr-xemail/aiaiai-email-dispatcher-helper2
-rwxr-xr-xemail/aiaiai-email-lda6
-rw-r--r--email/aiaiai-email-sh-functions2
-rwxr-xr-xemail/aiaiai-email-test-patchset4
-rwxr-xr-xjenkins/aiaiai-jenkins-test-patchset2
12 files changed, 29 insertions, 22 deletions
diff --git a/aiaiai-diff-log b/aiaiai-diff-log
index f0fa5b2..87de403 100755
--- a/aiaiai-diff-log
+++ b/aiaiai-diff-log
@@ -159,7 +159,7 @@ while true; do
shift
done
-[ "$#" = 3 ] || fatal 'Insufficient or too many arguments.'
+[ "$#" = 3 ] || die "Insufficient or too many arguments"
program_required "remap-log" \
"You probably did not compile it, run 'make' in the topmost aiaiai source code directory"
diff --git a/aiaiai-make-kernel b/aiaiai-make-kernel
index 7422903..a69d279 100755
--- a/aiaiai-make-kernel
+++ b/aiaiai-make-kernel
@@ -221,7 +221,7 @@ while true; do
shift
done
-[ "$#" -ge 2 ] || fatal 'Insufficient arguments'
+[ "$#" -ge 2 ] || die "Insufficient arguments"
program_required "aiaiai-locker" \
"You probably did not compile it, run 'make' in the topmost aiaiai source code directory"
diff --git a/aiaiai-match-keywords b/aiaiai-match-keywords
index 49e5256..4488853 100755
--- a/aiaiai-match-keywords
+++ b/aiaiai-match-keywords
@@ -77,7 +77,7 @@ while true; do
shift
done
-[ "$#" -eq 1 ] || fatal 'Please, specify exactly one argument - the file with keywords'
+[ "$#" -eq 1 ] || die "Please, specify exactly one argument - the file with keywords"
file="$(readlink -ev -- "$1")"
while IFS= read -r kw; do
diff --git a/aiaiai-sh-functions b/aiaiai-sh-functions
index 2f4a4a1..57fe04d 100644
--- a/aiaiai-sh-functions
+++ b/aiaiai-sh-functions
@@ -9,6 +9,13 @@
if [ -z "${__included_aiaiai_sh_functions-}" ]; then
__included_aiaiai_sh_functions=1
+# Print an error message and exit
+# Usage: die <message>
+die()
+{
+ fatal "Fatal error: $1"
+}
+
# Print a separator line to stdout
print_separator()
{
@@ -31,7 +38,7 @@ program_required()
if ! command -v "$prg" >/dev/null 2>&1; then
message "Program \"$prg\" is required but not found in PATH"
if [ -n "$msg" ]; then
- fatal "$msg"
+ die "$msg"
else
exit 1
fi
@@ -61,7 +68,7 @@ fetch_header_or_die()
local hdr="$1"; shift
local res="$(fetch_header "$hdr")"
- [ -n "$res" ] || fatal "Cannot find the \"$hdr:\" header"
+ [ -n "$res" ] || die "Cannot find the \"$hdr:\" header"
eval "$var=\"\$res\""
}
@@ -86,7 +93,7 @@ git_dir()
elif [ -d "$path" ]; then
printf "%s" "$path"
else
- fatal "not a git repository: $path"
+ die "not a git repository: $path"
fi
}
diff --git a/aiaiai-test-bisectability b/aiaiai-test-bisectability
index 130a8ec..8e0adb2 100755
--- a/aiaiai-test-bisectability
+++ b/aiaiai-test-bisectability
@@ -184,7 +184,7 @@ while true; do
shift
done
-[ "$#" -eq 2 ] || fatal 'Please, specify exactly 2 arguments - the kernel tree and the configuration'
+[ "$#" -eq 2 ] || die "Please, specify exactly 2 arguments - the kernel tree and the configuration"
kernel_tree="$(readlink -ev -- "$1")"; shift
defconfig="$(leave_first "$1")";
diff --git a/aiaiai-test-patchset b/aiaiai-test-patchset
index 7f6be63..36cd304 100755
--- a/aiaiai-test-patchset
+++ b/aiaiai-test-patchset
@@ -154,14 +154,14 @@ test_configuration()
if [ -n "$confdir" ]; then
defconfig="$confdir/$defconfig"
- [ -f "$defconfig" ] || fatal "$defconfig is not available"
+ [ -f "$defconfig" ] || die "$defconfig is not available"
fi
if [ -n "$bisectability" ]; then
# We share the same source tree with 'aiaiai-test-bisectability', so
# wait for it (it could be run at the previous iteration)
if [ -n "$pid_bisect" ]; then
- wait "$pid_bisect" || fatal "aiaiai-test-bisectability failed"
+ wait "$pid_bisect" || die "aiaiai-test-bisectability failed"
pid_bisect=
fi
@@ -325,7 +325,7 @@ while true; do
shift
done
-[ "$#" -ge 2 ] || fatal 'Insufficient arguments'
+[ "$#" -ge 2 ] || die "Insufficient arguments"
kernel_tree="$(readlink -ev -- "$1")"; shift
defconfigs="$@"
@@ -433,9 +433,9 @@ for defconfig in $defconfigs; do
test_configuration "$defconfig"
done
-wait "$pid_checkpatch" || fatal "checkpatch failed"
-[ -z "$keywords" ] || wait "$pid_keywords" || fatal "aiaiai-match-keywords failed"
-[ -z "$pid_bisect" ] || wait "$pid_bisect" || fatal "aiaiai-test-bisectability failed"
+wait "$pid_checkpatch" || die "checkpatch failed"
+[ -z "$keywords" ] || wait "$pid_keywords" || die "aiaiai-match-keywords failed"
+[ -z "$pid_bisect" ] || wait "$pid_bisect" || die "aiaiai-test-bisectability failed"
# Print the results
diff --git a/email/aiaiai-email-dispatcher b/email/aiaiai-email-dispatcher
index c8a0d8a..4e303d9 100755
--- a/email/aiaiai-email-dispatcher
+++ b/email/aiaiai-email-dispatcher
@@ -113,7 +113,7 @@ while true; do
shift
done
-[ "$#" -eq 2 ] || fatal "Insufficient or too many arguments"
+[ "$#" -eq 2 ] || die "Insufficient or too many arguments"
program_required "inotifywait" ""
diff --git a/email/aiaiai-email-dispatcher-helper b/email/aiaiai-email-dispatcher-helper
index 5f02d65..ab65849 100755
--- a/email/aiaiai-email-dispatcher-helper
+++ b/email/aiaiai-email-dispatcher-helper
@@ -75,7 +75,7 @@ while true; do
shift
done
-[ "$#" -eq 4 ] || fatal "Insufficient or too many arguments"
+[ "$#" -eq 4 ] || die "Insufficient or too many arguments"
mbox=$(readlink -fv -- "$1"); shift
fail_file="$1"; shift
diff --git a/email/aiaiai-email-lda b/email/aiaiai-email-lda
index 2159165..e8f7939 100755
--- a/email/aiaiai-email-lda
+++ b/email/aiaiai-email-lda
@@ -236,7 +236,7 @@ EOF
dir="$(printf "%s" "$series_relatives" | sed -e "s/\(.*\)\/.*/\1/" | sort -u)"
message "Found series directory \"$dir\""
[ "$(printf "%s" "$dir" | wc -l)" -eq 0 ] ||
- fatal "Relatives live in different series directories!"
+ die "Relatives live in different series directories!"
fi
# Move the relatives from the staging to the series directory
@@ -364,7 +364,7 @@ while true; do
shift
done
-[ "$#" -eq 2 ] || fatal "Insufficient or too many arguments"
+[ "$#" -eq 2 ] || die "Insufficient or too many arguments"
program_required "mutt" ""
program_required "find" ""
@@ -421,7 +421,7 @@ while IFS= read -r line; do
message "The last line of previous mbox is not blank"
message "line: $line"
message "prev: $prev"
- fatal "exiting"
+ die "exiting"
fi
process_mbox
truncate -s0 -- "$mbox"
diff --git a/email/aiaiai-email-sh-functions b/email/aiaiai-email-sh-functions
index 38a2740..0fbeb94 100644
--- a/email/aiaiai-email-sh-functions
+++ b/email/aiaiai-email-sh-functions
@@ -120,7 +120,7 @@ __ini_config_get_or_die()
local result="$(ini_config_get "$1" "$2" "$3")"
[ -n "$result" ] ||
- fatal "Could not find config option \"$2.$3\" in \"$1\""
+ die "Could not find config option \"$2.$3\" in \"$1\""
eval "$var=\"\$result\""
}
diff --git a/email/aiaiai-email-test-patchset b/email/aiaiai-email-test-patchset
index 826f183..83eff04 100755
--- a/email/aiaiai-email-test-patchset
+++ b/email/aiaiai-email-test-patchset
@@ -153,7 +153,7 @@ while true; do
shift
done
-[ "$#" -eq 1 ] || fatal "Insufficient or too many arguments"
+[ "$#" -eq 1 ] || die "Insufficient or too many arguments"
program_required "mutt" ""
program_required "grep" ""
@@ -190,7 +190,7 @@ cc="$(fetch_header "Cc" < "$mbox")"
# Either "To:" or "Cc:" must exist
if [ -z "$to" ] && [ -z "$cc" ]; then
- fatal "Neither \"To:\" nor \"Cc:\" header found"
+ die "Neither \"To:\" nor \"Cc:\" header found"
fi
# Find out the project name
diff --git a/jenkins/aiaiai-jenkins-test-patchset b/jenkins/aiaiai-jenkins-test-patchset
index 4936d4f..fe7306e 100755
--- a/jenkins/aiaiai-jenkins-test-patchset
+++ b/jenkins/aiaiai-jenkins-test-patchset
@@ -173,7 +173,7 @@ while true; do
shift
done
-[ "$#" -ge 4 ] || fatal 'Insufficient arguments'
+[ "$#" -ge 4 ] || die "Insufficient arguments"
[ -n "$tmpdir" ] || tmpdir="$(mktemp -dt "$PROG.XXXX")"