]> www.infradead.org Git - users/dedekind/aiaiai.git/commitdiff
Use a helper for the 'fatal()' function
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Mon, 2 Dec 2013 12:14:04 +0000 (14:14 +0200)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Tue, 3 Dec 2013 13:27:55 +0000 (15:27 +0200)
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>
12 files changed:
aiaiai-diff-log
aiaiai-make-kernel
aiaiai-match-keywords
aiaiai-sh-functions
aiaiai-test-bisectability
aiaiai-test-patchset
email/aiaiai-email-dispatcher
email/aiaiai-email-dispatcher-helper
email/aiaiai-email-lda
email/aiaiai-email-sh-functions
email/aiaiai-email-test-patchset
jenkins/aiaiai-jenkins-test-patchset

index f0fa5b2403b39da94a0d214fe759e541d4e3c17c..87de4033e36e0885bdd698118878e47405009628 100755 (executable)
@@ -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"
index 74229037a10852705e1cbcfad103a7415cd768ba..a69d27945fecf4b6509f5d503e27da711084170b 100755 (executable)
@@ -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"
index 49e5256f7ced85ad327a6ca5a1affb7ccfb45ef2..448885352c5c5ba9f09ede20fd7ff77e396e114a 100755 (executable)
@@ -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
index 2f4a4a146ba608ff5f7a4107756e65358311f673..57fe04d7495a56299c5a040821201b65b09a4a81 100644 (file)
@@ -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
 }
 
index 130a8ecce5c53feadca640fec07a6d2fba579096..8e0adb2755a4b02dad96798f54d096f32a8e1572 100755 (executable)
@@ -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")";
index 7f6be63c20119f4cf4fe3932ceaf07911d54c7ca..36cd304eb88fd8f8adfd7fe5820c632423c7bc35 100755 (executable)
@@ -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
 
index c8a0d8abdf1759ea6967b7482cd2a83cd21c29c7..4e303d980504f24b8241c3c66c2895b4218875c8 100755 (executable)
@@ -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" ""
 
index 5f02d6572b0411d69476e8df4e219055e9b7a0d2..ab65849c2bfb5f52ebcf8178289c6b9e8a0fc028 100755 (executable)
@@ -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
index 2159165728396daf31688558f471ea5e158f370e..e8f793915acdd5766789a2506b51e16c0dd7e5f7 100755 (executable)
@@ -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"
index 38a274013d9fdb681d0ac64c110b88f5ea46e081..0fbeb94c9d7cac6acfa01bab831b43814a716520 100644 (file)
@@ -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\""
 }
index 826f183cd6aec813460dcba46f145dd1007c286d..83eff04c02b1e1fea4314cee21c22bfca1fbde5f 100755 (executable)
@@ -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
index 4936d4ff180005fc76c231f6f9c37c401166d8e5..fe7306e16476a20e7e787ca2018136c6d306c29b 100755 (executable)
@@ -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")"